使用 sklearn.linear_model.lasso_path 等函数时,如果 return_models 设置为 False,则返回值是 alpha 和系数。但是,不会返回路径的截距,这意味着无法应用系数来预测新数据。或者,人们可以要求返回模型,但从我收到的警告来看,返回模型似乎很快就会被弃用:
DeprecationWarning: Use enet_path(return_models=False), as it returns the coefficients and alphas instead of just a list of models as previously
lasso_path
/enet_path
did.return_models
will eventually be removed in 0.15, after which, returning alphas and coefs will become the norm.
那么,如何获得包含系数、alpha 和截距的完整路径?
最佳答案
一个快速的技巧是附加您的 X 矩阵的新列为 1。然后截距只是成为系数之一。
关于scikit-learn - 从 sklearn enet_path 返回拦截,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22667567/