Closed aisthesis closed 8 years ago
Here's where I'm coming from on the formula: http://stackoverflow.com/questions/27476933/numpy-linear-regression-with-regularization
I'm pretty confident that the formula is correct. Here's my result using sklearn
:
>>> from sklearn.linear_model import Ridge
>>> clf = Ridge(alpha=3., solver='svd')
>>> clf.fit(features['train'], labels['train'])
Ridge(alpha=3.0, copy_X=True, fit_intercept=True, max_iter=None,
normalize=False, random_state=None, solver='svd', tol=0.001)
>>> clf.coef_
array([ 0. , 6.52208421, 3.82487688, 3.61985418, 2.18396316,
2.10604481, 1.2807778 , 1.28789997, 0.72492414])
>>> clf.intercept_
11.217589325366376
>>> predicted = clf.predict(features['test'])
>>> pn.learn.mse(predicted, labels['test'])
array([[ 7.14405231]])
i mostly have some minor comments. other than that it looks good to go
some replies on your comments. other than that good to go.
Simple tool for performing regularized linear regression.