File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,20 @@ def predict(self, X):
57
57
raise NotImplementedError (
58
58
"This clustering algorithm does not support predicting." )
59
59
60
+ def __eq__ (self , other ):
61
+ if self is other :
62
+ return True
63
+ print (self .labels , other .labels )
64
+ return type (self ) is type (other ) \
65
+ and self .projector == other .projector \
66
+ and self .domain == other .domain \
67
+ and self .original_domain == other .original_domain \
68
+ and self .labels == other .labels
69
+
70
+ def __hash__ (self ):
71
+ # TODO handle labels
72
+ return hash ((self .projector , self .domain , self .original_domain ))
73
+
60
74
61
75
class Clustering (metaclass = WrapperMeta ):
62
76
"""
Original file line number Diff line number Diff line change @@ -19,6 +19,15 @@ def __init__(self, projector):
19
19
def predict (self , X ):
20
20
return self .projector .predict (X )
21
21
22
+ def __eq__ (self , other ):
23
+ return super ().__eq__ (other ) \
24
+ and self .centroids == other .centroids \
25
+ and self .k == other .k
26
+
27
+ def __hash__ (self ):
28
+ # TODO self.centroids
29
+ return hash ((super ().__hash__ (), self .k ))
30
+
22
31
23
32
class KMeans (Clustering ):
24
33
You can’t perform that action at this time.
0 commit comments