上篇用Keras预测,效果不好。今天尝试了决策树。然并卵!
再采集了2021一年得足球数据之后用人工智能做预测
依赖数据有半场进攻次数那些,进3场10场平均信息,这里有44%,加入欧盘初盘上升到46%
大小盘,亚盘加入后没发现对准确率有提升。
准确率依旧再
下半场胜平负:46%
角球准确率:51%
大小球未测
- # -*- coding: utf-8 -*-
- import numpy as np
- import pandas as pd
-
-
- dftrain_raw = pd.read_csv('C:/Users/xxx/Desktop/365/c/角球分析/corner.txt',header=None, encoding="gbk",low_memory=False)
- #print(dftrain_raw[1])
- dftest_raw = pd.read_csv('C:/Users/xxx/Desktop/365/c/角球分析/cornerp.txt',header=None, encoding="gbk",low_memory=False)
- #dftrain_raw.head(10)
- #print(dftrain_raw[21])
-
-
- #win_index=3
- # 数据预处理2
- def preprocessing2(dfdata):
-
- dfresult= pd.DataFrame()
- dfresult= dfdata
-
- del dfresult[0]
- dfresult[1]=dfdata[1]/500000
- dfresult[2]=dfdata[2]/500000
-
- #dfresult.iloc[:,3:55]=dfresult.iloc[:,3:55]/10
- del dfresult[win_index]
- #return(df_min_max(dfresult,0,1))
- return(dfresult)
-
-
- win_index=2
- # 数据预处理2
- def preprocessing(dfdata):
-
- dfresult= pd.DataFrame()
- dfresult= dfdata
-
- dfresult[0]=dfdata[0]/500000
- dfresult[1]=dfdata[1]/500000
-
- #dfresult.iloc[:,2:73]=dfresult.iloc[:,2:73]/10
- del dfresult[win_index]
- return(dfresult)
-
-
- y_train = dftrain_raw[win_index]
- print(y_train)
- x_train = preprocessing(dftrain_raw)
- print(x_train)
- print(x_train.shape)
-
-
- y_test = dftest_raw[win_index]
- #print(y_test)
- x_test = preprocessing(dftest_raw)
- print(x_test)
- print(x_test.shape)
-
-
-
- # 导入LogisticRegression方法
- from sklearn.linear_model import LogisticRegression
- from sklearn.tree import DecisionTreeClassifier
- # 训练模型
- model = DecisionTreeClassifier(random_state = 1, splitter='best',criterion='entropy',max_depth=3)
- #model = LogisticRegression(verbose=1,max_iter=3000)
- model.fit(x_train, y_train,)
-
- #model.score(x_test, y_test)
-
-
- y_new = model.predict(x_test)
- print(y_test)
- print(y_new)
-
- from sklearn.metrics import classification_report
- print(classification_report(y_test, y_new))