We are going to do some work towards building our own scikit-learn estimator. The custom scikit-learn estimator consists of at least three methods:
- An __init__ initialization method: This method takes as input the estimator's parameters
- A fit method: This trains the estimator
- A predict method: This method performs a prediction on unseen data
Schematically, the class looks like this:
#Inherit from the classes BaseEstimator, ClassifierMixin
class RidgeClassifier(BaseEstimator, ClassifierMixin):
def __init__(self,param1,param2):
self.param1 = param1
self.param2 = param2
def fit(self, X, y = None):
#do as much work as possible in this method
return self
def predict(self, X_test):
#do some work here and return the predictions, y_pred
return y_pred