我正在try 使用我的线性回归()模型根据新的x值进行预测.X值在我的回归模型的范围内.我的代码如下:
x=df[['A']]
y=df['B']
m = LinearRegression()
m.fit(x,y)
# Test new X
new_x=pd.DataFrame([0.4])
print(m.predict(new_x))
[-28.43482247] UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names
warnings.warn(
使用上面的错误.问题是:
-
我不确定这个警告告诉了我什么.
-
The value given to me is not right, because the new_x value i entered was on the regression line (I outputted this on the graph). And my graph is also x>=0, y>=0 . Here is a picture of my scatter plot:
我也有不到一百万张唱片.
编辑:2的解决方案是因为我解释错了数字.它实际上应该是"0.4e7",这给了我预期的答案.