python - 运行多个线性回归测试时精度没有增加

我做了一个非常简单的程序,它从 csv 文件中获取数据列,这是文件数据的简短预览:

,matchId,blue_win,blueGold,blueMinionsKilled,blueJungleMinionsKilled,blueAvgLevel,redGold,redMinionsKilled,redJungleMinionsKilled,redAvgLevel,blueChampKills,blueHeraldKills,blueDragonKills,blueTowersDestroyed,redChampKills,redHeraldKills,redDragonKills,redTowersDestroyed
0,3493250918.0,0,24575.0,349.0,89.0,8.6,25856.0,346.0,80.0,9.2,6.0,1.0,0.0,1.0,12.0,2.0,0.0,1.0
1,3464936341.0,0,27210.0,290.0,36.0,9.0,28765.0,294.0,92.0,9.4,20.0,0.0,0.0,0.0,19.0,2.0,0.0,0.0
2,3428425921.0,1,32048.0,346.0,92.0,9.4,25305.0,293.0,84.0,9.4,17.0,3.0,0.0,0.0,11.0,0.0,0.0,4.0
3,3428347390.0,0,20261.0,223.0,60.0,8.2,30429.0,356.0,107.0,9.4,7.0,0.0,0.0,3.0,16.0,3.0,0.0,0.0
4,3428350940.0,1,30217.0,376.0,110.0,9.8,23889.0,334.0,60.0,8.8,16.0,3.0,0.0,0.0,8.0,0.0,0.0,2.0
5,3494458885.0,1,25470.0,362.0,82.0,9.2,22856.0,319.0,86.0,8.8,9.0,1.0,0.0,0.0,7.0,1.0,0.0,0.0
6,3463320642.0,1,25391.0,350.0,96.0,9.2,23236.0,345.0,80.0,8.6,8.0,2.0,0.0,0.0,5.0,1.0,0.0,1.0
...

我删除了不必要的列并使用 30% 的数据作为测试数据运行测试,以预测蓝队赢得比赛的准确性:

import pandas as pd
import numpy as np
import sklearn
from sklearn import linear_model

df = pd.read_csv('MatchTimelinesFirst15.csv', delimiter=',')

predict = "blue_win"

df = df.drop('Unnamed: 0', axis=1)
df = df.drop('redDragonKills', axis=1)
df = df.drop('blueDragonKills', axis=1)
# print(df.describe())

x = np.array(df.drop([predict], axis=1))
y = np.array(df[predict])


for _ in range(500):
    x_train, x_test, y_train, y_test = sklearn.model_selection.train_test_split(x, y, test_size=0.30)

    # print('{0}, {1}'.format(type(x_train), x_train))

    linear = linear_model.LinearRegression()

    # trains model
    linear.fit(x_train, y_train)

    acc = linear.score(x_test, y_test)

    print('Accuracy: {0}'.format(acc))

但是即使通过循环训练 500 次,我的准确性也不会提高?我不断得到相同范围的结果:

Accuracy: 0.39030223064480596
Accuracy: 0.3980014684661366
Accuracy: 0.3840247556358104
Accuracy: 0.3939949181269252
Accuracy: 0.38657487661026535
Accuracy: 0.3950506154649621
Accuracy: 0.3925506648304995
...

任何帮助都将不胜感激,因为我对 python 和 machine learning 还很陌生,因此也有助于改进。

回答1

您不会使用循环进一步训练模型。您每 500 次重新开始,唯一的区别是您训练测试拆分的随机初始化。

至于你的分类器的改进,我会避开Linear Regression。回归与分类不同。分类将预测分类类别标签,而回归预测连续数量。

由于您想知道蓝队何时获胜,因此您遇到了二元分类问题。蓝队要么赢,要么不赢。

尝试分类模型,如 https://scikit-learn.org/stable/modules/classes.html#module-sklearn.svm

祝你好运!

相似文章

git - 删除大小写差异的远程分支

最近,我应该在研究一个名为“回归”的分支。我不小心做出了对“回归”的承诺。因为更改相对较小,所以我决定只写下它们的内容并完全重置我的本地状态,它现在没有分支。我想删除远程分支“回归”,而不是在过程中删...

最新文章