英雄联盟大师 Baseline

秋伟君_5077

秋伟君_5077

2025-07-21

897人浏览

原创

该赛事围绕英雄联盟实时对局数据预测胜负展开。提供18万训练数据与2万测试数据,含击杀、伤害等30个字段,需预测测试集“win”标签,以准确率评分。Baseline流程含环境配置、代码运行等步骤,采用简单神经网络模型,还可通过提取交叉特征、加入验证集等优化模型提升成绩。

☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 多模态理解力帮你轻松跨越从0到1的创作门槛☜☜☜

英雄联盟大师 baseline - php中文网

赛事介绍

实时对战游戏是人工智能研究领域的一个热点。由于游戏复杂性、部分可观察和动态实时变化战局等游戏特点使得研究变得比较困难。我们可以在选择英雄阶段预测胜负概率,也可以在比赛期间根据比赛实时数据进行建模。那么我们英雄联盟对局进行期间,能知道自己的胜率吗?

英雄联盟大师 Baseline - php中文网

赛事任务

比赛数据使用了英雄联盟玩家的实时游戏数据,记录下用户在游戏中对局数据(如击杀数、住物理伤害)。希望参赛选手能从数据集中挖掘出数据的规律,并预测玩家在本局游戏中的输赢情况。

赛题训练集案例如下:

  • 训练集18万数据;
  • 测试集2万条数据;
import pandas as pdimport numpy as nptrain = pd.read_csv('train.csv.zip')

对于数据集中每一行为一个玩家的游戏数据,数据字段如下所示:

Git Pro
Git Pro

Git高级操作:smart-commit、rebase、bisect、worktree、reflog、冲突解决、子模块、PR流程

下载
  • id:玩家记录id
  • win:是否胜利,标签变量
  • kills:击杀次数
  • deaths:死亡次数
  • assists:助攻次数
  • largestkillingspree:最大 killing spree(游戏术语,意味大杀特杀。当你连续杀死三个对方英雄而中途没有死亡时)
  • largestmultikill:最大mult ikill(游戏术语,短时间内多重击杀)
  • longesttimespentliving:最长存活时间
  • doublekills:doublekills次数
  • triplekills:doublekills次数
  • quadrakills:quadrakills次数
  • pentakills:pentakills次数
  • totdmgdealt:总伤害
  • magicdmgdealt:魔法伤害
  • physicaldmgdealt:物理伤害
  • truedmgdealt:真实伤害
  • largestcrit:最大暴击伤害
  • totdmgtochamp:对对方玩家的伤害
  • magicdmgtochamp:对对方玩家的魔法伤害
  • physdmgtochamp:对对方玩家的物理伤害
  • truedmgtochamp:对对方玩家的真实伤害
  • totheal:治疗量
  • totunitshealed:痊愈的总单位
  • dmgtoturrets:对炮塔的伤害
  • timecc:法控时间
  • totdmgtaken:承受的伤害
  • magicdmgtaken:承受的魔法伤害
  • physdmgtaken:承受的物理伤害
  • truedmgtaken:承受的真实伤害
  • wardsplaced:侦查守卫放置次数
  • wardskilled:侦查守卫摧毁次数
  • firstblood:是否为firstblood 测试集中label字段win为空,需要选手预测。

评审规则

  1. 数据说明

选手需要提交测试集队伍排名预测,具体的提交格式如下:

win0110
  1. 评估指标

本次竞赛的使用准确率进行评分,数值越高精度越高,评估代码参考:

from sklearn.metrics import accuracy_score
y_pred = [0, 2, 1, 3]y_true = [0, 1, 2, 3]accuracy_score(y_true, y_pred)

Baseline使用指导

1、点击‘fork按钮’,出现‘fork项目’弹窗
2、点击‘创建按钮’ ,出现‘运行项目’弹窗
3、点击‘运行项目’,自动跳转至新页面
4、点击‘启动环境’ ,出现‘选择运行环境’弹窗
5、选择运行环境(启动项目需要时间,请耐心等待),出现‘环境启动成功’弹窗,点击确定
6、点击进入环境,即可进入notebook环境
7、鼠标移至下方每个代码块内(代码块左侧边框会变成浅蓝色),再依次点击每个代码块左上角的‘三角形运行按钮’,待一个模块运行完以后再运行下一个模块,直至全部运行完成
英雄联盟大师 Baseline - php中文网
英雄联盟大师 Baseline - php中文网
8、下载页面左侧submission.zip压缩包
英雄联盟大师 Baseline - php中文网
9、在比赛页提交submission.zip压缩包,等待系统评测结束后,即可登榜!
英雄联盟大师 Baseline - php中文网
10、点击页面左侧‘版本-生成新版本’
英雄联盟大师 Baseline - php中文网
11、填写‘版本名称’,点击‘生成版本按钮’,即可在个人主页查看到该项目(可选择公开此项目哦)

In [1]
import pandas as pdimport paddleimport numpy as np
%pylab inlineimport seaborn as sns

train_df = pd.read_csv('data/data137276/train.csv.zip')
test_df = pd.read_csv('data/data137276/test.csv.zip')

train_df = train_df.drop(['id', 'timecc'], axis=1)
test_df = test_df.drop(['id', 'timecc'], axis=1)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/__init__.py:107: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import MutableMapping
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/rcsetup.py:20: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Iterable, Mapping
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Sized
Populating the interactive namespace from numpy and matplotlib

数据分析

In [3]
train_df.isnull().mean(0)
win                       0.0
kills                     0.0
deaths                    0.0
assists                   0.0
largestkillingspree       0.0
largestmultikill          0.0
longesttimespentliving    0.0
doublekills               0.0
triplekills               0.0
quadrakills               0.0
pentakills                0.0
totdmgdealt               0.0
magicdmgdealt             0.0
physicaldmgdealt          0.0
truedmgdealt              0.0
largestcrit               0.0
totdmgtochamp             0.0
magicdmgtochamp           0.0
physdmgtochamp            0.0
truedmgtochamp            0.0
totheal                   0.0
totunitshealed            0.0
dmgtoturrets              0.0
totdmgtaken               0.0
magicdmgtaken             0.0
physdmgtaken              0.0
truedmgtaken              0.0
wardsplaced               0.0
wardskilled               0.0
firstblood                0.0
dtype: float64
In [4]
train_df['win'].value_counts().plot(kind='bar')
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/cbook/__init__.py:2349: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  if isinstance(obj, collections.Iterator):
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/cbook/__init__.py:2366: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  return list(data) if isinstance(data, collections.MappingView) else data
<matplotlib.axes._subplots.axessubplot></matplotlib.axes._subplots.axessubplot>
<figure></figure>
In [5]
sns.distplot(train_df['kills'])
<matplotlib.axes._subplots.axessubplot></matplotlib.axes._subplots.axessubplot>
<figure></figure>
In [5]
sns.distplot(train_df['deaths'])
<matplotlib.axes._subplots.axessubplot></matplotlib.axes._subplots.axessubplot>
<figure></figure>
In [6]
sns.boxplot(y='kills', x='win', data=train_df)
<matplotlib.axes._subplots.axessubplot></matplotlib.axes._subplots.axessubplot>
<figure></figure>
In [7]
plt.scatter(train_df['kills'], train_df['deaths'])
plt.xlabel('kills')
plt.ylabel('deaths')
Text(0,0.5,'deaths')
<figure></figure>
In [8]
for col in train_df.columns[1:]:
    train_df[col] /= train_df[col].max()
    test_df[col] /= test_df[col].max()

搭建模型

In [9]
class Classifier(paddle.nn.Layer):
    # self代表类的实例自身
    def __init__(self):
        # 初始化父类中的一些参数
        super(Classifier, self).__init__()
        
        self.fc1 = paddle.nn.Linear(in_features=29, out_features=40)
        self.fc2 = paddle.nn.Linear(in_features=40, out_features=1)
        self.relu = paddle.nn.ReLU()    
    # 网络的前向计算
    def forward(self, inputs):
        x = self.relu(self.fc1(inputs))
        x = self.fc2(x)        return x
In [10]
model = Classifier()
model.train()
opt = paddle.optimizer.SGD(learning_rate=0.01, parameters=model.parameters())
loss_fn = paddle.nn.BCEWithLogitsLoss()
W0427 14:43:44.334179   103 device_context.cc:447] Please NOTE: device: 0, GPU Compute Capability: 8.0, Driver API Version: 11.2, Runtime API Version: 11.2
W0427 14:43:44.338698   103 device_context.cc:465] device: 0, cuDNN Version: 8.2.
In [11]
EPOCH_NUM = 2   # 设置外层循环次数BATCH_SIZE = 100  # 设置batch大小training_data = train_df.iloc[:-1000,].values.astype(np.float32)
val_data = train_df.iloc[-1000:, ].values.astype(np.float32)# 定义外层循环for epoch_id in range(EPOCH_NUM):    # 在每轮迭代开始之前,将训练数据的顺序随机的打乱
    
    np.random.shuffle(training_data)    
    # 将训练数据进行拆分,每个batch包含10条数据
    mini_batches = [training_data[k:k+BATCH_SIZE] for k in range(0, len(training_data), BATCH_SIZE)]    
    # 定义内层循环
    for iter_id, mini_batch in enumerate(mini_batches):
        x = np.array(mini_batch[:, 1:]) # 获得当前批次训练数据
        y = np.array(mini_batch[:, :1]) # 获得当前批次训练标签
        
        # 将numpy数据转为飞桨动态图tensor的格式
        features = paddle.to_tensor(x)
        y = paddle.to_tensor(y)        
        # 前向计算
        predicts = model(features)        
        # 计算损失
        loss = loss_fn(predicts, y, )
        avg_loss = paddle.mean(loss)        if iter_id%200==0:
            acc = (predicts > 0).astype(int).flatten() == y.flatten().astype(int)
            acc = acc.astype(float).mean()            print("epoch: {}, iter: {}, loss is: {}, acc is {}".format(epoch_id, iter_id, avg_loss.numpy(), acc.numpy()))        
        # 反向传播,计算每层参数的梯度值
        avg_loss.backward()        # 更新参数,根据设置好的学习率迭代一步
        opt.step()        # 清空梯度变量,以备下一轮计算
        opt.clear_grad()
epoch: 0, iter: 0, loss is: [0.6994627], acc is [0.49]
epoch: 0, iter: 200, loss is: [0.7009081], acc is [0.36]
epoch: 0, iter: 400, loss is: [0.6921266], acc is [0.57]
epoch: 0, iter: 600, loss is: [0.6839013], acc is [0.64]
epoch: 0, iter: 800, loss is: [0.6739801], acc is [0.75]
epoch: 0, iter: 1000, loss is: [0.65885824], acc is [0.83]
epoch: 0, iter: 1200, loss is: [0.66508365], acc is [0.71]
epoch: 0, iter: 1400, loss is: [0.6578212], acc is [0.74]
epoch: 0, iter: 1600, loss is: [0.6562445], acc is [0.72]
epoch: 1, iter: 0, loss is: [0.6200185], acc is [0.85]
epoch: 1, iter: 200, loss is: [0.62804365], acc is [0.79]
epoch: 1, iter: 400, loss is: [0.6358215], acc is [0.75]
epoch: 1, iter: 600, loss is: [0.6242084], acc is [0.76]
epoch: 1, iter: 800, loss is: [0.6128205], acc is [0.78]
epoch: 1, iter: 1000, loss is: [0.6186602], acc is [0.68]
epoch: 1, iter: 1200, loss is: [0.57297456], acc is [0.79]
epoch: 1, iter: 1400, loss is: [0.57423747], acc is [0.78]
epoch: 1, iter: 1600, loss is: [0.58428985], acc is [0.75]
In [12]
model.eval()
test_data = paddle.to_tensor(test_df.values.astype(np.float32))
test_predict = model(test_data)
test_predict = (test_predict > 0).astype(int).flatten()
In [13]
pd.DataFrame({'win':
              test_predict.numpy()
             }).to_csv('submission.csv', index=None)

!zip submission.zip submission.csv
updating: submission.csv (deflated 90%)

总结与上分点

  1. 原始赛题字段存在关联,可以进一步提取交叉特征。
  2. 模型训练过程中可以加入验证集验证过程。
In [ ]
<br>

相关文章

PHP速学视频免费教程(入门到精通)
PHP速学视频免费教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

python git 热点

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
数据分析的方法
数据分析的方法

数据分析的方法有:对比分析法,分组分析法,预测分析法,漏斗分析法,AB测试分析法,象限分析法,公式拆解法,可行域分析法,二八分析法,假设性分析法。php中文网为大家带来了数据分析的相关知识、以及相关文章等内容。

2023.07.04

1962

6

数据分析方法有哪几种
数据分析方法有哪几种

数据分析方法有:1、描述性统计分析;2、探索性数据分析;3、假设检验;4、回归分析;5、聚类分析。本专题为大家提供数据分析方法的相关的文章、下载、课程内容,供大家免费下载体验。

2023.08.07

2750

5

网站建设功能有哪些
网站建设功能有哪些

网站建设功能包括信息发布、内容管理、用户管理、搜索引擎优化、网站安全、数据分析、网站推广、响应式设计、社交媒体整合和电子商务等功能。这些功能可以帮助网站管理员创建一个具有吸引力、可用性和商业价值的网站,实现网站的目标。

2023.10.16

7430

14

数据分析网站推荐
数据分析网站推荐

数据分析网站推荐:1、商业数据分析论坛;2、人大经济论坛-计量经济学与统计区;3、中国统计论坛;4、数据挖掘学习交流论坛;5、数据分析论坛;6、网站数据分析;7、数据分析;8、数据挖掘研究院;9、S-PLUS、R统计论坛。想了解更多数据分析的相关内容,可以阅读本专题下面的文章。

2024.03.13

3124

8

Python 数据分析处理
Python 数据分析处理

本专题聚焦 Python 在数据分析领域的应用,系统讲解 Pandas、NumPy 的数据清洗、处理、分析与统计方法,并结合数据可视化、销售分析、科研数据处理等实战案例,帮助学员掌握使用 Python 高效进行数据分析与决策支持的核心技能。

2025.09.08

4825

12

Python 数据分析与可视化
Python 数据分析与可视化

本专题聚焦 Python 在数据分析与可视化领域的核心应用,系统讲解数据清洗、数据统计、Pandas 数据操作、NumPy 数组处理、Matplotlib 与 Seaborn 可视化技巧等内容。通过实战案例(如销售数据分析、用户行为可视化、趋势图与热力图绘制),帮助学习者掌握 从原始数据到可视化报告的完整分析能力。

2025.10.14

7432

24

Python 数据分析与可视化合集
Python 数据分析与可视化合集

聚焦 Python 在数据分析领域的核心应用,讲解 NumPy 数组运算、Pandas 数据清洗与聚合统计、缺失值与异常值处理、数据透视表生成,以及使用 Matplotlib、Seaborn、Pyecharts 制作折线图、柱状图、热力图、地图等多种可视化图表,适合数据分析师和运营人员快速掌握用 Python 从原始数据中挖掘洞察的能力。

2026.04.08

376

25

Python数据分析与Pandas高级实战
Python数据分析与Pandas高级实战

本专题围绕 Python 数据分析展开,系统讲解 Pandas 的高级用法,包括数据清洗、透视表、时间序列分析以及多表合并与分组操作。通过实战案例,帮助开发者掌握高效处理与分析数据的方法,提高数据处理效率与分析能力。

2026.04.13

771

25

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程