繁体   English   中英

如何使用scipy的curve_fit规范线性回归?

[英]How can I regularize a linear regression with scipy's curve_fit?

我最近精通使用Python / scipy curve_fit进行线性回归。 但是,对于高阶多项式,我的数据有时过拟合。

如何添加正则化以减少过度拟合?

我想知道套索处罚是否对您有用

# 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)

应该在交叉验证期间选择最佳λ。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM