scikit-learn - 从 sklearn enet_path 返回拦截

标签 scikit-learn

使用 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/

相关文章:

scikit-learn - sklearn : Found arrays with inconsistent numbers of samples when calling LinearRegression. 适合()

python - 使用具有稀疏和密集矩阵的 sklearn RandomizedPCA 时的不同结果

python - Scikit-learn 获取样本属于某个类别的概率

scikit-learn - sklearn metrics.log_loss 是正值 vs. 得分 'neg_log_loss' 是负值

python - 处理泰坦尼克号机器学习 train.csv 中的空数据点

python - Sklearn 算法列表

python - GridseachCV - 值错误 : Found input variables with inconsistent numbers of samples: [33 1]

python - sklearn.cluster.KMeans 如何处理缺少质心的 init ndarray 参数(可用质心小于 n_clusters)?

python - 如何在 Python 中为余弦相似度运行一个大矩阵?

python - sklearn.feature_selection 中除 Chi-2 之外的特征选择指标