svc预测概率_分析1982场英雄联盟数据,教你开局前预测游戏对局胜负!

英雄联盟想必大多数读者不会陌生,这是一款来自拳头,由腾

讯代理的大型网络游戏,现在一进网吧,你就能发现一大片玩英雄联盟的人。在2017年中国战队无缘鸟巢的世界总决赛后,一大片人选择了弃游,只是终究没躲过“真香定理”,在2018年的中旬,又有大批战友又回到熟悉的召唤师峡谷战场,时至今日,英雄联盟已经不仅仅是一款游戏,一个电竞项目了,它已经成为了我们生活的快乐源泉了。

cda71ae6484a99d9f689bd70674ee006.png

问君能有几多愁,辅助闪现抢人头;问君能有几多愁,卡牌千里送人头。问君能有几多愁,皇子开大关队友;清明时节雨纷纷,各种队友各种坑。别人笑我不买眼,我笑别人浪费钱;孤帆远影碧空尽,草丛惊现蛮易信 。相见时难别亦难,碰见赵信菊花残;我自横刀向天笑,剁人只需用三刀。苦练盲僧千百次, 盲目对战N 多次;战输不下五十次, 砸得鼠标要出事;举杯邀明月,草丛遇盖伦。

鉴于现在喜欢英雄联盟的大佬如此之多,为了帮助大家尽快的拿到首胜,小编爬取并分析了1982余场LOL数据。非常神奇的是!在开局之前能够高概率的预测本局的胜负!让你提前做好心理准备。需要源码的滴滴小编!

假设

假设没有王者等大神代玩小号

假设没有代练

假设没有因为半途被媳妇抓到而挂机的行为

假设没有突然掉网连不上去的行为

游戏对战数据获取

国服:腾讯游戏平台非官方API - http://www.games-cube.com/

751fa8a51ad61f19a866d71b41c3e89e.png

外服:Riot开发者平台API- https://developer.riotgames.com/

ba8e3fdc381ababcff69da0a228d21d2.png

连接数据库:

import numpy as np

import pymysql, random, json

def connect_db(database):

try:

conn = pymysql.connect(host='localhost', port=3306, user='root', password='zandaoguang', db=database, charset='utf8')

return conn

except:

print ('Exception: MySQL Connection')

return None

分析和训练数据

利用神经网络(neural_network)、随机森林(random_forest)和支持向量机(support_vector)等若干智能算法进行训练和回归,最终进行比较效果。

下面为神经网络部分代码:

from __future__ import print_function

import numpy as np

#np.random.seed(1337) # for reproducibility

from keras.datasets import mnist

from keras.models import Sequential, load_model

from keras.layers import Dense, Dropout, Activation, Flatten

from keras.layers import Convolution2D, MaxPooling2D

from keras.utils import np_utils

from keras import backend as K

from keras.optimizers import SGD, Adam, RMSprop

import gzip

import sys

from six.moves import cPickle

from fetcher import *

batch_size = 256

nb_classes = 2

nb_epoch = 100

champion_dict = fetch_champion_dict("champion136.json")

champion_num = len(champion_dict)

X_train = X_train.astype('int8')

X_test = X_test.astype('int8')

print('X_train shape:', X_train.shape)

print(X_train.shape[0], 'train samples')

print(X_test.shape[0], 'test samples')

Y_train = np_utils.to_categorical(y_train, nb_classes)

Y_test = np_utils.to_categorical(y_test, nb_classes)

model = Sequential()

model.add(Dense(1500, input_dim = champion_num, init='uniform'))

model.add(Activation('sigmoid'))

model.add(Dense(2))

model.add(Activation('softmax'))

model.summary()

model.compile(loss='categorical_crossentropy',

optimizer=RMSprop(),

metrics=['accuracy'])

history = model.fit(X_train, Y_train,

batch_size=batch_size, nb_epoch=nb_epoch,

verbose=1, validation_data=(X_test, Y_test))

score = model.evaluate(X_test, Y_test, verbose=0)

print('Test score:', score[0])

print('Test accuracy:', score[1])

随机森林代码:

from sklearn.ensemble import RandomForestClassifier

from sklearn.externals import joblib

from fetcher import *

champion_dict = fetch_champion_dict("champion136.json")

champion_num = len(champion_dict)

X_train, y_train, X_test, y_test = fetch_one_side_riot('12', 'MATCHED_GAME', 'KING_PORO', 'KINGPORO', ('1492660800000', '1493740800000'), champion_dict)

clf = RandomForestClassifier(n_estimators=500, n_jobs=2)

clf.fit(X_train, y_train)

train_score = clf.score(X_train, y_train)

print ("Train Score = "+str(train_score))

test_score = clf.score(X_test, y_test)

print ("Test Score = "+str(test_score))

支持向量机代码:

from sklearn.externals import joblib

from sklearn import svm

from fetcher import *

champion_dict = fetch_champion_dict("champion136.json")

champion_num = len(champion_dict)

X_train, y_train, X_test, y_test = fetch_one_side_riot('12', 'MATCHED_GAME', 'ARAM_UNRANKED_5x5', 'ARAM', ('1492660800000', '1493740800000'), champion_dict)

clf = svm.SVC()

clf.fit(X_train, y_train)

train_score = clf.score(X_train, y_train)

print ("Train Score = "+str(train_score))

test_score = clf.score(X_test, y_test)

print ("Test Score = "+str(test_score))

游戏对战胜负预测

根据双方英雄阵容,预测获胜方的准确率(%)

PS:由于阿广近期没有玩英雄联盟,所以分析的数据为2017年的游戏数据。

75e69452242b7168ceda70bacda0ce5b.png

只根据本方英雄阵容,预测本方能否获胜的准确率(%)

5f617b28fea1bc90932363bbecf6880f.png

期望研究的问题

LOL中游戏胜利是否与能性别有关?

LOL的胜率是否和每天的时间段有关系?

在女朋友阻止自己玩游戏的情况下,LOL的胜率下降多少?如何解决?

注:由于数据量太小,以后能收集到更多的数据,是希望可以对上面以及更多的方向进行研究。

结论

LOL取得最后胜利的三个重要因素为:团队阵容、团队水平,配合默契度。

合理的分配BUFF也是游戏胜利的必要因素。

打游戏的心态也是游戏胜利一个不可或缺的条件。

结语:

虽然我们通过机器学习算法可以预测这把的输赢,但是这毕竟不是我们最后的结果。玩英雄联盟和爱情类似,明明知道是我们不可能,却坚持去追求,这正是爱的美丽。也许没有什么结果,可那过程本身的美丽便足够用一生去品味。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值