def regression_ex(term='final'): keylst = [ 100115, 100245, 100246, 100374, 100003, 100004, 100020, 100285, 100159, 100287, 100288, 100164, 100300, 100179, 100053, 100183, 100315, 100061, 100193, 100066, 100457, 100343, 100217, 100434, 100249, 100316, 100329, 100019, 100340, 100041, 100069 ] keylst = [val for val in keylst for i in range(3024)] from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error, r2_score prp = PreProcessor(term) # 数据管理器 train_x, train_y, test_x = prp.load_traindata() # 训练模型 lr = LinearRegression() # print(train_x.iloc[:, 0:1]) lr.fit(train_x.iloc[:, 0:1].values, train_y) test_y = lr.predict(test_x.values) # print(test_y) return test_y