LinearRegression()中的coef_值代表什么?

时间:2019-06-25 02:51:54

标签: python machine-learning scikit-learn linear-regression

是机器学习的初学者。这只是一个简单的问题,LinearRegression()中的coef_代表什么?我知道它代表系数,但我不了解这些值,高coef_和正coef_是否意味着更牢固的关系?

而且,如果coef_值是指数值,那是否表示我的LinearRegression错误?

array([-3.12840684e+02, -1.01279891e+13, -1.42682874e+13, -1.42682874e+13,
   -1.42682873e+13, -1.42682873e+13, -1.23057091e+04, -6.08730443e+02,
   -2.25836847e+12, -2.25836846e+12, -2.25836846e+12, -2.25836846e+12,
   -2.25836845e+12, -2.25836846e+12, -2.25836846e+12, -2.25836847e+12,
   -2.25836849e+12,  5.41669310e+11,  5.41669341e+11,  5.41669325e+11,
    2.47680574e+12,  5.41669172e+11,  5.41669322e+11,  5.41669336e+11,
    5.41669320e+11, -1.92388659e+12, -1.92388658e+12, -1.92388659e+12,
   -1.92388654e+12, -1.43004842e+12, -1.92388655e+12, -1.92388658e+12,
   -1.92388665e+12, -1.92388657e+12, -1.92388658e+12, -1.92388653e+12,
   -1.92388658e+12, -1.92388660e+12, -1.92388658e+12, -1.92388660e+12,
   -9.83609518e+11, -9.83609497e+11, -9.83609551e+11, -9.83609529e+11,
   -1.47744767e+12, -9.83609560e+11, -9.83609506e+11, -9.83609465e+11,
   -9.83609519e+11, -9.83609455e+11, -9.83609513e+11, -9.83609555e+11,
   -9.83609535e+11, -9.83609497e+11, -9.83609511e+11, -9.83609514e+11,
   -1.54590339e+13, -1.54590339e+13, -1.54590339e+13, -1.54590339e+13,
   -1.30678844e+12, -1.30678843e+12, -1.30678843e+12, -1.30678847e+12,
   -1.30678844e+12, -1.62361585e+13, -1.62361585e+13, -1.62361585e+13,
   -1.62361585e+13, -1.62361586e+13, -1.62361585e+13,  5.88718912e+12,
    5.88718906e+12,  5.88718908e+12,  5.88718907e+12, -5.88718905e+12,
   -5.88718905e+12, -5.88718906e+12, -5.88718904e+12,  3.45085841e+11,
    3.45085830e+11,  3.45085861e+11,  3.45085814e+11,  3.45085829e+11,
    3.45085830e+11,  3.11126022e+12,  3.11126021e+12,  3.11126021e+12,
    1.13335966e+07,  3.11126021e+12, -7.58191433e+11, -7.58191424e+11,
    3.04834491e+03,  3.74262207e+03, -1.19176646e+04, -1.16855749e+04,
    2.00192065e+03,  3.75148918e+12,  3.75148916e+12,  3.75148918e+12,
    3.75148928e+12,  2.24187815e+13,  2.24187815e+13,  2.24187815e+13,
    2.24187815e+13,  6.26624305e+04,  1.61187017e+04,  2.00000527e+04,
   -3.10534619e+03,  2.39790901e+04, -7.55683101e+12, -7.55683096e+12,
   -7.55683096e+12, -7.55683096e+12, -7.55683097e+12, -7.55683097e+12,
    2.32335100e+13,  2.32335100e+13,  2.32335100e+13, -1.15363807e+13,
   -1.15363808e+13, -1.15363807e+13, -1.15363807e+13, -1.15363807e+13,
    2.70555822e+12,  2.70555822e+12,  2.70555823e+12, -3.19955267e+11,
   -3.19955228e+11, -3.19955165e+11, -3.19955294e+11, -3.19955247e+11,
   -3.19955264e+11, -3.19955255e+11, -3.19955270e+11, -3.19955263e+11,
   -4.86759426e+12, -4.86759423e+12, -4.86759425e+12, -4.86759428e+12,
   -4.86759425e+12, -4.86759427e+12])

2 个答案:

答案 0 :(得分:1)

至少阅读您正在使用的scikit学习模块的标题页是明智之举。

https://scikit-learn.org/stable/modules/linear_model.html 对于线性回归: $ \ hat {y}(w,x)= w_0 + w_1 x_1 + ... + w_p x_p $

在整个模块中,我们将系数\ w的向量指定为coef_和intercept _。

答案 1 :(得分:1)

coef_为您提供了一系列通过线性回归估算的权重。它的形状为(n_targets,n_features)。在您的情况下,它是一维数组,因为您只有一个目标。

在您的情况下,权重具有巨大的价值,请确保对功能进行归一化并为模型使用正则化。