Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/classifiers/nmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ def class_labels(self):
return self._class_labels

def fit(self, xtr, ytr):
self.class_labels = np.unique(ytr)

centroids_list = []

for c in self._class_labels:
indices = np.where(ytr == c)[0]
x_current = xtr[indices, :]
centroid_c = np.mean(x_current, axis=0)
centroids_list.append(centroid_c)
self._centroids = np.array(centroids_list)
pass

def predict(self, xts):
Expand Down