深度学习之sklearn决策树

上篇用Keras预测,效果不好。今天尝试了决策树。然并卵!

再采集了2021一年得足球数据之后用人工智能做预测

依赖数据有半场进攻次数那些,进3场10场平均信息,这里有44%,加入欧盘初盘上升到46%
大小盘,亚盘加入后没发现对准确率有提升。

准确率依旧再

下半场胜平负:46%
角球准确率:51%
大小球未测
 

  1. # -*- coding: utf-8 -*-
  2. import numpy as np
  3. import pandas as pd
  4.  
  5.  
  6. dftrain_raw = pd.read_csv('C:/Users/xxx/Desktop/365/c/角球分析/corner.txt',header=None, encoding="gbk",low_memory=False)
  7. #print(dftrain_raw[1])
  8. dftest_raw = pd.read_csv('C:/Users/xxx/Desktop/365/c/角球分析/cornerp.txt',header=None, encoding="gbk",low_memory=False)
  9. #dftrain_raw.head(10)
  10. #print(dftrain_raw[21])
  11.  
  12.  
  13. #win_index=3
  14. # 数据预处理2
  15. def preprocessing2(dfdata):
  16.  
  17. dfresult= pd.DataFrame()
  18. dfresult= dfdata
  19.  
  20. del dfresult[0]
  21. dfresult[1]=dfdata[1]/500000
  22. dfresult[2]=dfdata[2]/500000
  23.  
  24. #dfresult.iloc[:,3:55]=dfresult.iloc[:,3:55]/10
  25. del dfresult[win_index]
  26. #return(df_min_max(dfresult,0,1))
  27. return(dfresult)
  28.  
  29.  
  30. win_index=2
  31. # 数据预处理2
  32. def preprocessing(dfdata):
  33.  
  34. dfresult= pd.DataFrame()
  35. dfresult= dfdata
  36.  
  37. dfresult[0]=dfdata[0]/500000
  38. dfresult[1]=dfdata[1]/500000
  39.  
  40. #dfresult.iloc[:,2:73]=dfresult.iloc[:,2:73]/10
  41. del dfresult[win_index]
  42. return(dfresult)
  43.  
  44.  
  45. y_train = dftrain_raw[win_index]
  46. print(y_train)
  47. x_train = preprocessing(dftrain_raw)
  48. print(x_train)
  49. print(x_train.shape)
  50.  
  51.  
  52. y_test = dftest_raw[win_index]
  53. #print(y_test)
  54. x_test = preprocessing(dftest_raw)
  55. print(x_test)
  56. print(x_test.shape)
  57.  
  58.  
  59.  
  60. # 导入LogisticRegression方法
  61. from sklearn.linear_model import LogisticRegression
  62. from sklearn.tree import DecisionTreeClassifier
  63. # 训练模型
  64. model = DecisionTreeClassifier(random_state = 1, splitter='best',criterion='entropy',max_depth=3)
  65. #model = LogisticRegression(verbose=1,max_iter=3000)
  66. model.fit(x_train, y_train,)
  67.  
  68. #model.score(x_test, y_test)
  69.  
  70.  
  71. y_new = model.predict(x_test)
  72. print(y_test)
  73. print(y_new)
  74.  
  75. from sklearn.metrics import classification_report
  76. print(classification_report(y_test, y_new))

发表评论

邮箱地址不会被公开。 必填项已用*标注