def predict(self, X):
    return [self.combine(x) for x in X]

def classify(self, inputs):
    return sign(self.predict(inputs))

def fit(self, X, y, **kwargs):
    self.l = kwargs['l']
X = np.matrix(X)
y = np.matrix(y)
W = (X.transpose() * X).getI() * X.transpose() * y
self.weights = [w[0] for w in W.tolist()]

def get_params(self, deep=False):
    return {'l': self.l}
X = np.matrix([[0, 0], [1, 0], [0, 1], [1, 1]])
y = np.matrix([0, 1, 1, 0]).transpose()
print(cross_val_score(RegularizedRegressor(), X, y, fit_params={'l': 0.1},
    scoring='mean_squared_error'))
How to write a custom estimator in sklearn and use cross-validation on it?