I have this piece of code:
def separate_sets(self):
self.groups = {}
self.group_names = list(set(self.y))
if len(self.group_names) > 2:
print ('more than two classes provided...exiting')
sys.exit()
#putting all the samples in a regular order so that their
#grouping can be easier.
combined = sorted(zip(self.x, self.y), key = lambda n: n[1])
#--doing val,key here because (x,y) was zipped
for val,key in combined:
if self.groups.has_key(key):
self.groups[key].append(val)
else:
self.groups[key] = []
self.groups[key].append(val)
#train on each group
self.train()
And I received the following error message:
if self.groups.has_key(key):
AttributeError: 'dict' object has no attribute 'has_key'
has_keywas deprecated. Are you using Python 3 by any chance?