ITPub博客

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

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

作者:deeply 时间:2019-11-07 10:38:21 0 删除 编辑
就是我行对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。请问这个应该怎么办呢,越简单越好。


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1978/viewspace-3140737/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-05-30

  • 博文量
    215
  • 访问量
    24534