Last active
October 15, 2018 15:13
-
-
Save georgepar/b53c01466d6649c8583497d120b9b479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.base import BaseEstimator, ClassifierMixin | |
class EuclideanClassifier(BaseEstimator, ClassifierMixin): | |
"""Classify samples based on the distance from the mean feature value""" | |
def __init__(self): | |
self.X_mean_ = None | |
def fit(self, X, y): | |
""" | |
This should fit classifier. All the "work" should be done here. | |
Calculates self.X_mean_ based on the mean | |
feature values in X for each class. | |
self.X_mean_ becomes a numpy.ndarray of shape | |
(n_classes, n_features) | |
fit always returns self. | |
""" | |
raise NotImplementedError | |
#return self | |
def predict(self, X): | |
""" | |
Make predictions for X based on the | |
euclidean distance from self.X_mean_ | |
""" | |
raise NotImplementedError | |
def score(self, X, y): | |
""" | |
Return accuracy score on the predictions | |
for X based on ground truth y | |
""" | |
raise NotImplementedError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment