I have recently become proficient at using Python/scipy curve_fit to perform linear regression. However, with higher order polynomials, my data is sometimes overfit.
How can I add regularization to reduce over-fitting?
I was wondering whether lasso penalization works for you:
# the high order items can be integrated into X (such as x1^2,x1*x2), and change it into a linear regression problem again
lasso.fit(X, y)
# the selection range of lambda can be determined by yourself.
LassoCV(lambda=array([ 2, 1,9, ..., 0.2 , 0.1]),
copy_X=True, cv=None, eps=0.001, fit_intercept=True, max_iter=1000,
n_alphas=100, normalize=False, precompute=’auto’, tol=0.0001,
verbose=False)
The optimal lambda is supposed to be chosen during cross validation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With