【发布时间】:2021-06-14 04:19:01
【问题描述】:
尝试进行多项式回归并且在拟合模型时遇到了一些问题。 获取
ValueError: Found input variables with inconsistent numbers of samples: [1040, 260]
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
x = BTCdata.iloc[:, [1, 2, 4, 5]]
y = BTCdata.iloc[:,3]
x, y = np.array(x).reshape((-1, 1)), np.array(y).reshape((-1, 1))
poly_features= PolynomialFeatures(degree= 4, include_bias = False)
x_ = poly_features.fit_transform(x)
model = LinearRegression()
model.fit(x_, y)
【问题讨论】:
-
能否请您发布 BTCdata 或链接或类似内容以重现错误?
-
是的,当然是我没能做到这一点的错
-
drive.google.com/file/d/13VnQZbKB9UTOeNplT6GjzTZvH8CqxQcr/… sheet is 'FinalBTC' 。刚刚做了简单的 pd.read_excel(path)
标签: python numpy scikit-learn regression