In this chapter we will cover the following recipes:
-
Creating a simple estimator
In this chapter we will cover the following recipes:
Creating a simple estimator
We are going to make a custom estimator with scikit-learn. We will take traditional statistical math and programming and turn it into machine learning. You are able to turn any statistics into machine learning by using scikit-learn's powerful cross-validation capabilities.
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:
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