我一直在网上浏览各种 MOOC,其中提到其中一个在 scikit 中将一列包含到线性回归的训练数据中。
假设我有以下训练数据集:
investment loan
300000 12000
431000 3000
900000 4000
320000 2000
在适合 python 中的 LinearRegression 的 scikit 模型之前,我是否需要附加如下列?
ones investment loan
1 300000 12000
1 431000 3000
1 900000 4000
1 320000 2000
感谢任何帮助。
请您参考如下方法:
来自docs :
fit_intercept : boolean, optional, default True
whether to calculate the intercept for this model. If set to False, no intercept will be used in calculations (e.g. data is expected to be already centered).
截距 是与“1 列”相关的系数。因此,如果此参数设置为 True(默认值),则不需要 1 列。
