重塑线性回归的数据

时间:2017-11-19 07:17:17

标签: python scikit-learn linear-regression

我正在尝试在python中创建一个线性回归模型。代码如下

time_values = np.linspace(1,23,23) # print from 1,2...23
number_of_clients = [] # create empty list that will hold number of clients
for i in range(1,24,1):
    rand_vlaue = random.randint(1,20) # generate number of clients
    number_of_clients.append(rand_vlaue)

print time_values
print number_of_clients

model = LinearRegression()
model.fit(time_values,number_of_clients)
model.predict(24)

运行时出现以下错误

Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

0 个答案:

没有答案