machine-learning - 线性回归 : Need to clarify the Coef*Feature meaning

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

有人可以解释一下我是否有因变量,例如结果 (y),定义为

y = K1*F1 + K2*F2 + ... + Kn*Fn + E

每 n 个特征,其中 K - 系数,F - 特征(分类特征和连续特征),E - 误差

那么这是否意味着K1*F1是每1个特征的结果?

最佳答案

简短回答: 是的,就是这个意思(如果您不考虑 E)。

长答案: 请参阅下面我刚刚在 Jupyter 上完成的代码。

如您所见,我生成了一些带有一些“噪声”的数据,然后将其与 sklearn.linear_model.LinearRegression 进行拟合。然后我得到我的系数(+截距),你会看到回归实际上是 x.coeff+截距,如果我是对的,这就是你的 K1*F1

from sklearn.linear_model import LinearRegression
import numpy as np
from matplotlib import pyplot as plt

noise = 2

lr = LinearRegression()
x, y = [], []
i=0
while i<10:
    for j in range(np.random.randint(1,5)):
        x.append(i)
        y.append(i+np.random.rand()*noise+(noise/2))
    i+=np.random.rand()

%matplotlib inline
plt.scatter(x, y)

x = np.asarray(x).reshape(-1, 1)
y = np.asarray(y).reshape(-1)

lr.fit(x,y)
plt.plot(x, np.multiply(x, lr.coef_[0])+lr.intercept_)

Linear Regression

关于machine-learning - 线性回归 : Need to clarify the Coef*Feature meaning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35338270/

相关文章:

python - 如何在不使用 Python 中的外部库的情况下解析 arff 文件

r - R 上泊松回归的预测区间

machine-learning - 为什么word2vec不使用正则化?

python - Keras的evaluate_generator准确率和scikit learn的accuracy_score不一致

python - 将字典中的数据打乱以用于测试和训练数据

python - 将 Scaler 与 LassoCV、RidgeCV 一起使用

python - MLPClassifier参数设置

R 中数据帧的回归

machine-learning - Nesterov的第三种方法——Python中的实现

python - pybrain NNregression工具参数