我有训练数据帧。这是他们的一部分
date city brand model price count
2016-03 moscow bmw 5-series 1 млн - 2 млн 5
2016-05 moscow bmw 5-series 500 тыс - 1 млн 3
2016-06 moscow bmw 5-series 1 млн - 2 млн 4
2016-09 moscow bmw 5-series до 200 тыс 4
我需要预测到2016-12
测试数据框
date city brand model
2016-12 moscow bmw 5-series
我尝试使用linear regression
X = pd.read_excel('result_drom2.xlsx')
X_predict = pd.read_excel('test.xlsx')
y = pd.DataFrame()
y['count'] = X['count']
del X['count']
label = LabelEncoder()
def cat_to_num(df, column):
dicts = {}
label.fit(df[column].drop_duplicates())
dicts[column] = list(label.classes_)
df[column] = label.transform(df[column])
cat_to_num(X, 'date')
cat_to_num(X, 'city')
cat_to_num(X, 'brand')
cat_to_num(X, 'model')
cat_to_num(X, 'price')
cat_to_num(X_predict, 'date')
cat_to_num(X_predict, 'city')
cat_to_num(X_predict, 'brand')
cat_to_num(X_predict, 'model')
cat_to_num(X_predict, 'price')
model = LinearRegression()
model.fit(X, y)
y_predict = model.predict(X_predict)
但我有[ 2.17593916]
。并且所有数据都不同,但我获得的所有值都在1.5 and 2.7
之间。它是否正确,我如何评价,这与最后的数据有一些共同之处?