首页 新闻 搜索 专区 学院

简单的机器学习更改,指定数据集预测

0
[已关闭问题] 关闭于 2020-02-02 00:03
复制代码
就是我行对train文件训练后,直接训练test.xls。请问这个应该怎么办呢,越简单越好。

import
numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns #from competition.ml import score %matplotlib inline %config InlineBackend.figure_format = 'retina' %config IPCompleter.greedy = True %config IPCompleter.use_jedi = True pd.options.display.max_colwidth = 100 plt.rcParams['figure.figsize'] = (12, 8) train_path = r'C:\Users\MyPC\Desktop\train.xls' test_path = r'C:\Users\MyPC\Desktop\test.xls' train = pd.read_excel(train_path) test = pd.read_excel(test_path) train.shape, test.shape train.info() test.info() train.head() test.head() train.describe() test.describe() from sklearn.ensemble import ExtraTreesClassifier model=ExtraTreesClassifier() trainX=train[['X1','X2','X3','X4','X5','X6','X7','X8','X9','X10','X11','X12','X13','X14','X15','X16','X17','X18','X19','X20','X21','X22','X23']] trainY=train['Y'] testX=train[['X1','X2','X3','X4','X5','X6','X7','X8','X9','X10','X11','X12','X13','X14','X15','X16','X17','X18','X19','X20','X21','X22','X23']] testY=train['Y'] model.fit(trainX,trainY) y_pred =model.predict(testX)#######预测 np.savetxt(r'C:\Users\MyPC\Desktop\predict.csv', y_pred) #score(y_pred)



就是我行对train文件训练后,直接训练test.xls。请问这个应该怎么办呢,越简单越好。
复制代码
and技术梦的主页 and技术梦 | 初学一级 | 园豆:2
提问于:2019-11-07 06:57
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册