大吉大利,今晚吃鸡~ 今天跟朋友玩了几把吃鸡,经历了各种死法,还被嘲笑说论女生吃鸡的100种死法,比如被拳头抡死、跳伞落到房顶边缘摔死 、把吃鸡玩成飞车被车技秀死、被队友用燃烧瓶烧死的。这种游戏对我来说就是一个让我明白原来还有这种死法的游戏。但是玩归玩,还是得假装一下我沉迷学习,所以今天就用吃鸡比赛的真实数据来看看如何提高你吃鸡的概率。

那么我们就用 Python 和 R 做数据分析来回答以下的灵魂发问?

首先来看下数据:

跳哪儿危险?

对于我这样一直喜欢苟着的良心玩家,在经历了无数次落地成河的惨痛经历后,我是坚决不会选择跳P城这样楼房密集的城市,穷归穷但保命要紧。所以我们决定统计一下到底哪些地方更容易落地成河?我们筛选出在前100秒死亡的玩家地点进行可视化分析。激情沙漠地图的电站、皮卡多、别墅区、依波城最为危险,火车站、火电厂相对安全。绝地海岛中P城、军事基地、学校、医院、核电站、防空洞都是绝对的危险地带。物质丰富的G港居然相对安全。

 1import numpy as np 2import matplotlib.pyplot as plt 3import pandas as pd 4import seaborn as sns 5from scipy.misc.pilutil import imread 6import matplotlib.cm as cm 7 8#导入部分数据 9deaths1 = pd.read_csv("deaths/kill_match_stats_final_0.csv")10deaths2 = pd.read_csv("deaths/kill_match_stats_final_1.csv")1112deaths = pd.concat([deaths1, deaths2])1314#打印前5列,理解变量15print (deaths.head(),'\n',len(deaths))1617#两种地图18miramar = deaths[deaths["map"] == "MIRAMAR"]19erangel = deaths[deaths["map"] == "ERANGEL"]2021#开局前100秒死亡热力图22position_data = ["killer_position_x","killer_position_y","victim_position_x","victim_position_y"]23for position in position_data:24    miramar[position] = miramar[position].apply(lambda x: x*1000/800000)25    miramar = miramar[miramar[position] != 0]2627    erangel[position] = erangel[position].apply(lambda x: x*4096/800000)28    erangel = erangel[erangel[position] != 0]2930n = 5000031mira_sample = miramar[miramar["time"] < 100].sample(n)32eran_sample = erangel[erangel["time"] < 100].sample(n)3334# miramar热力图35bg = imread("miramar.jpg")36fig, ax = plt.subplots(1,1,figsize=(15,15))37ax.imshow(bg)38sns.kdeplot(mira_sample["victim_position_x"], mira_sample["victim_position_y"],n_levels=100, cmap=cm.Reds, alpha=0.9)3940# erangel热力图41bg = imread("erangel.jpg")42fig, ax = plt.subplots(1,1,figsize=(15,15))43ax.imshow(bg)44sns.kdeplot(eran_sample["victim_position_x"], eran_sample["victim_position_y"], n_levels=100,cmap=cm.Reds, alpha=0.9)

苟着还是出去干?

我到底是苟在房间里面还是出去和敌人硬拼?这里因为比赛的规模不一样,这里选取参赛人数大于90的比赛数据,然后筛选出团队team_placement即最后成功吃鸡的团队数据:

1、先计算了吃鸡团队平均击杀敌人的数量,这里剔除了四人模式的比赛数据,因为人数太多的团队会因为数量悬殊平均而变得没意义;

2、所以我们考虑通过分组统计每一组吃鸡中存活到最后的成员击杀敌人的数量,但是这里发现数据统计存活时间变量是按照团队最终存活时间记录的,所以该想法失败;

3、最后统计每个吃鸡团队中击杀人数最多的数量统计,这里剔除了单人模式的数据,因为单人模式的数量就是每组击杀最多的数量。最后居然发现还有击杀数量达到60的,怀疑是否有开挂。想要吃鸡还是得出去练枪法,光是苟着是不行的。

 1library(dplyr) 2library(tidyverse) 3library(data.table) 4library(ggplot2) 5pubg_full <- fread("../agg_match_stats.csv") 6# 吃鸡团队平均击杀敌人的数量 7attach(pubg_full) 8pubg_winner <- pubg_full %>% filter(team_placement==1&party_size<4&game_size>90)  9detach(pubg_full)10team_killed <- aggregate(pubg_winner$player_kills, by=list(pubg_winner$match_id,pubg_winner$team_id), FUN="mean")11team_killed$death_num <- ceiling(team_killed$x)12ggplot(data = team_killed) + geom_bar(mapping = aes(x = death_num, y = ..count..), color="steelblue") +13  xlim(0,70) + labs(title = "Number of Death that PUBG Winner team Killed", x="Number of death")1415# 吃鸡团队最后存活的玩家击杀数量16pubg_winner <- pubg_full %>% filter(pubg_full$team_placement==1) %>% group_by(match_id,team_id)17attach(pubg_winner)18team_leader <- aggregate(player_survive_time~player_kills, data = pubg_winner, FUN="max")19detach(pubg_winner)2021# 吃鸡团队中击杀敌人最多的数量22pubg_winner <- pubg_full %>% filter(pubg_full$team_placement==1&pubg_full$party_size>1)23attach(pubg_winner)24team_leader <- aggregate(player_kills, by=list(match_id,team_id), FUN="max")25detach(pubg_winner)26ggplot(data = team_leader) + geom_bar(mapping = aes(x = x, y = ..count..), color="steelblue") +27  xlim(0,70) + labs(title = "Number of Death that PUBG Winner Killed", x="Number of death")28

哪一种武器干掉的玩家多?

运气好挑到好武器的时候,你是否犹豫选择哪一件?从图上来看,M416和SCAR是不错的武器,也是相对容易能捡到的武器,大家公认Kar98k是能一枪毙命的好枪,它排名比较靠后的原因也是因为这把枪在比赛比较难得,而且一下击中敌人也是需要实力的,像我这种捡到98k还装上8倍镜但没捂热乎1分钟的玩家是不配得到它的。

 1#杀人武器排名 2death_causes = deaths['killed_by'].value_counts() 3 4sns.set_context('talk') 5fig = plt.figure(figsize=(30, 10)) 6ax = sns.barplot(x=death_causes.index, y=[v / sum(death_causes) for v in death_causes.values]) 7ax.set_title('Rate of Death Causes') 8ax.set_xticklabels(death_causes.index, rotation=90) 910#排名前20的武器11rank = 2012fig = plt.figure(figsize=(20, 10))13ax = sns.barplot(x=death_causes[:rank].index, y=[v / sum(death_causes) for v in death_causes[:rank].values])14ax.set_title('Rate of Death Causes')15ax.set_xticklabels(death_causes.index, rotation=90)1617#两个地图分开取18f, axes = plt.subplots(1, 2, figsize=(30, 10))19axes[0].set_title('Death Causes Rate: Erangel (Top {})'.format(rank))20axes[1].set_title('Death Causes Rate: Miramar (Top {})'.format(rank))2122counts_er = erangel['killed_by'].value_counts()23counts_mr = miramar['killed_by'].value_counts()2425sns.barplot(x=counts_er[:rank].index, y=[v / sum(counts_er) for v in counts_er.values][:rank], ax=axes[0] )26sns.barplot(x=counts_mr[:rank].index, y=[v / sum(counts_mr) for v in counts_mr.values][:rank], ax=axes[1] )27axes[0].set_ylim((0, 0.20))28axes[0].set_xticklabels(counts_er.index, rotation=90)29axes[1].set_ylim((0, 0.20))30axes[1].set_xticklabels(counts_mr.index, rotation=90)3132#吃鸡和武器的关系33win = deaths[deaths["killer_placement"] == 1.0]34win_causes = win['killed_by'].value_counts()3536sns.set_context('talk')37fig = plt.figure(figsize=(20, 10))38ax = sns.barplot(x=win_causes[:20].index, y=[v / sum(win_causes) for v in win_causes[:20].values])39ax.set_title('Rate of Death Causes of Win')40ax.set_xticklabels(win_causes.index, rotation=90)

队友的助攻是否助我吃鸡?

有时候一不留神就被击倒了,还好我爬得快让队友救我。这里选择成功吃鸡的队伍,最终接受1次帮助的成员所在的团队吃鸡的概率为29%,所以说队友助攻还是很重要的(再不要骂我猪队友了,我也可以选择不救你。)竟然还有让队友救9次的,你也是个人才。

 1library(dplyr) 2library(tidyverse) 3library(data.table) 4library(ggplot2) 5pubg_full <- fread("E:/aggregate/agg_match_stats_0.csv") 6attach(pubg_full) 7pubg_winner <- pubg_full %>% filter(team_placement==1)  8detach(pubg_full) 9ggplot(data = pubg_winner) + geom_bar(mapping = aes(x = player_assists, y = ..count..), fill="#E69F00") +10  xlim(0,10) + labs(title = "Number of Player assisted", x="Number of death")11ggplot(data = pubg_winner) + geom_bar(mapping = aes(x = player_assists, y = ..prop..), fill="#56B4E9") +12  xlim(0,10) + labs(title = "Number of Player assisted", x="Number of death")

敌人离我越近越危险?

对数据中的killer_position和victim_position变量进行欧式距离计算,查看两者的直线距离跟被击倒的分布情况,呈现一个明显的右偏分布,看来还是需要随时观察到附近的敌情,以免到淘汰都不知道敌人在哪儿。

 1# python代码:杀人和距离的关系 2import math 3def get_dist(df): #距离函数 4    dist = [] 5   for row in df.itertuples(): 6        subset = (row.killer_position_x - row.victim_position_x)**2 + (row.killer_position_y - row.victim_position_y)**2 7        if subset > 0: 8            dist.append(math.sqrt(subset) / 100) 9         else:10            dist.append(0)11    return dist1213df_dist = pd.DataFrame.from_dict({'dist(m)': get_dist(erangel)})14df_dist.index = erangel.index1516erangel_dist = pd.concat([erangel,df_dist], axis=1)1718df_dist = pd.DataFrame.from_dict({'dist(m)': get_dist(miramar)})19df_dist.index = miramar.index2021miramar_dist = pd.concat([miramar,df_dist], axis=1)2223f, axes = plt.subplots(1, 2, figsize=(30, 10))24plot_dist = 1502526axes[0].set_title('Engagement Dist. : Erangel')27axes[1].set_title('Engagement Dist.: Miramar')2829plot_dist_er = erangel_dist[erangel_dist['dist(m)'] <= plot_dist]30plot_dist_mr = miramar_dist[miramar_dist['dist(m)'] <= plot_dist]3132sns.distplot(plot_dist_er['dist(m)'], ax=axes[0])33sns.distplot(plot_dist_mr['dist(m)'], ax=axes[1])

团队人越多我活得越久?

对数据中的party_size变量进行生存分析,可以看到在同一生存率下,四人团队的生存时间高于两人团队,再是单人模式,所以人多力量大这句话不是没有道理的。

乘车是否活得更久?

对死因分析中发现,也有不少玩家死于Bluezone,大家天真的以为捡绷带就能跑毒。对数据中的player_dist_ride变量进行生存分析,可以看到在同一生存率下,有开车经历的玩家生存时间高于只走路的玩家,光靠腿你是跑不过毒的。

小岛上人越多我活得更久?

对game_size变量进行生存分析发现还是小规模的比赛比较容易存活。

 1# R语言代码如下: 2library(magrittr) 3library(dplyr) 4library(survival) 5library(tidyverse) 6library(data.table) 7library(ggplot2) 8library(survminer) 9pubg_full <- fread("../agg_match_stats.csv")10# 数据预处理,将连续变量划为分类变量11pubg_sub <- pubg_full %>%12  filter(player_survive_time<2100) %>%13  mutate(drive = ifelse(player_dist_ride>0, 1, 0)) %>%14  mutate(size = ifelse(game_size<33, 1,ifelse(game_size>=33 &game_size<66,2,3)))15# 创建生存对象16surv_object <- Surv(time = pubg_sub$player_survive_time)17fit1 <- survfit(surv_object~party_size,data = pubg_sub)18# 可视化生存率19ggsurvplot(fit1, data = pubg_sub, pval = TRUE, xlab="Playing time [s]", surv.median.line="hv",20           legend.labs=c("SOLO","DUO","SQUAD"), ggtheme = theme_light(),risk.table="percentage")21fit2 <- survfit(surv_object~drive,data=pubg_sub)22ggsurvplot(fit2, data = pubg_sub, pval = TRUE, xlab="Playing time [s]", surv.median.line="hv",23           legend.labs=c("walk","walk&drive"), ggtheme = theme_light(),risk.table="percentage")24fit3 <- survfit(surv_object~size,data=pubg_sub)25ggsurvplot(fit3, data = pubg_sub, pval = TRUE, xlab="Playing time [s]", surv.median.line="hv",26           legend.labs=c("small","medium","big"), ggtheme = theme_light(),risk.table="percentage")

最后毒圈有可能出现的地点?

面对有本事能苟到最后的我,怎么样预测最后的毒圈出现在什么位置。从表agg_match_stats数据找出排名第一的队伍,然后按照match_id分组,找出分组数据里面player_survive_time最大的值,然后据此匹配表格kill_match_stats_final里面的数据,这些数据里面取第二名死亡的位置,作图发现激情沙漠的毒圈明显更集中一些,大概率出现在皮卡多、圣马丁和别墅区。绝地海岛的就比较随机了,但是还是能看出军事基地和山脉的地方更有可能是最后的毒圈。

 1#最后毒圈位置 2import matplotlib.pyplot as plt 3import pandas as pd 4import seaborn as sns 5from scipy.misc.pilutil import imread 6import matplotlib.cm as cm 7 8#导入部分数据 9deaths = pd.read_csv("deaths/kill_match_stats_final_0.csv")10#导入aggregate数据11aggregate = pd.read_csv("aggregate/agg_match_stats_0.csv")12print(aggregate.head())13#找出最后三人死亡的位置1415team_win = aggregate[aggregate["team_placement"]==1] #排名第一的队伍16#找出每次比赛第一名队伍活的最久的那个player17grouped = team_win.groupby('match_id').apply(lambda t: t[t.player_survive_time==t.player_survive_time.max()])1819deaths_solo = deaths[deaths['match_id'].isin(grouped['match_id'].values)]20deaths_solo_er = deaths_solo[deaths_solo['map'] == 'ERANGEL']21deaths_solo_mr = deaths_solo[deaths_solo['map'] == 'MIRAMAR']2223df_second_er = deaths_solo_er[(deaths_solo_er['victim_placement'] == 2)].dropna()24df_second_mr = deaths_solo_mr[(deaths_solo_mr['victim_placement'] == 2)].dropna()25print (df_second_er)2627position_data = ["killer_position_x","killer_position_y","victim_position_x","victim_position_y"]28for position in position_data:29    df_second_mr[position] = df_second_mr[position].apply(lambda x: x*1000/800000)30    df_second_mr = df_second_mr[df_second_mr[position] != 0]3132    df_second_er[position] = df_second_er[position].apply(lambda x: x*4096/800000)33    df_second_er = df_second_er[df_second_er[position] != 0]3435df_second_er=df_second_er36# erangel热力图37sns.set_context('talk')38bg = imread("erangel.jpg")39fig, ax = plt.subplots(1,1,figsize=(15,15))40ax.imshow(bg)41sns.kdeplot(df_second_er["victim_position_x"], df_second_er["victim_position_y"], cmap=cm.Blues, alpha=0.7,shade=True)4243# miramar热力图44bg = imread("miramar.jpg")45fig, ax = plt.subplots(1,1,figsize=(15,15))46ax.imshow(bg)47sns.kdeplot(df_second_mr["victim_position_x"], df_second_mr["victim_position_y"], cmap=cm.Blues,alpha=0.8,shade=True)

获取数据地址:https://www.kaggle.com/skihikingkevin/pubg-match-deaths#aggregate.zip。

此文花费了不少功夫,点赞、转发都是对作者的认可和支持。

最后祝大家:

声明:本文经授权转自经管人学数据分析,作者:胡萝卜酱。

(本文为AI科技大本营转载文章,转载请联系作者。)

征稿

推荐阅读:

  • 给Chrome“捉虫”16000个,Google开源bug自检工具

  • 2019全球AI 100强,中国占独角兽半壁江山,但忧患暗存

  • “百练”成钢:NumPy 100练

  • 赵本山:我的时代还没有结束 | Python告诉你

  • “不厚道”的程序员:年后第一天上班就提辞职

  • 微信帝国进化史:一个通讯工具如何在八年内制霸互联网?

  • Facebook神秘区块链部门首次收购,开放这些职位,你的技能符合吗?

  • 写给程序员的裁员防身指南

  • 这4门AI网课极具人气,逆天好评!(附代码+答疑)

点击“阅读原文”,打开CSDN APP 阅读更贴心!

用Python解锁“吃鸡”正确姿势相关推荐

  1. 教你用Python解锁“吃鸡”的正确姿势!(附240行代码)

    来源:经济人学数据分析 本文约2554字,建议阅读6分钟. 本文用Python分析吃鸡比赛的真实数据,解答至关重要的9个问题,助你提高吃鸡概率. 大吉大利,今晚吃鸡~ 今天跟朋友玩了几把吃鸡,经历了各 ...

  2. 教你用Python解锁“吃鸡”的正确姿势!

    本文用Python分析吃鸡比赛的真实数据,解答至关重要的9个问题,助你提高吃鸡概率. 大吉大利,今晚吃鸡~ 今天跟朋友玩了几把吃鸡,经历了各种死法,还被嘲笑说论女生吃鸡的100种死法,比如被拳头抡死. ...

  3. 大吉大利,今晚如何用 Python 解锁“吃鸡”的正确姿势

    大吉大利,今晚吃鸡~ 今天跟朋友玩了几把吃鸡,经历了各种死法,还被嘲笑说论女生吃鸡的100种死法,比如被拳头抡死.跳伞落到房顶边缘摔死 .把吃鸡玩成飞车被车技秀死.被队友用燃烧瓶烧死的.这种游戏对我来 ...

  4. python怎么安装scrapy_详解Python安装scrapy的正确姿势

    运行平台:Windows Python版本:Python3.x IDE:Sublime text3 一.Scrapy简介 Scrapy是一个为了爬取网站数据提取结构性数据而编写的应用框架,可以应用于数 ...

  5. Python制作吃鸡各数据资料查询助手,带你做理论王者~

    前言 大家早好.午好.晚好吖 ❤ ~ 吃鸡想必大家都玩过了 今天来教大家制作一个资料查询助手 1.我们是不是要去获取这些数据 武器配件 首先:对于 武器一个详情页url地址发送请求, 获取 每个武器的 ...

  6. 用Python解析吃鸡游戏的真相

    近期在Kaggle里发现一个有趣的项目.他提供了一个端游吃鸡的数据包,里面有近百局吃鸡游戏中各种游戏内部的量化数据,这绝壁是个好东西,能挖掘出各种有趣的结论.所以今天就用吃鸡比赛的真实数据来看看如何提 ...

  7. 利用python进行吃鸡(绝地求生)可视化分析

    相关数据下载,请关注公众号"一行数据",回复"pubg"可得 既然学习一段时间python了,那么得拿些好玩的东西练练手,这里通过加载几万局的吃鸡数据,来对吃鸡 ...

  8. 刺激战场—scrapy+selenium中间件+数据分析-带妹吃鸡正确方式

    数据获取-scrapy 如果这个都不了解一下,你怎么带妹吃鸡?老司机(小编)用了空余时间帮你分析一波,应该拿什么枪提升吃鸡几率,好的,进入正题了 未安装的请提前安装好,推荐一个地址scrapy-win ...

  9. Python 操作 MySQL 的正确姿势

    欢迎大家关注腾讯云技术社区-博客园官方主页,我们将持续在博客园为大家推荐技术精品文章哦~ 作者:邵建永 使用Python进行MySQL的库主要有三个,Python-MySQL(更熟悉的名字可能是MyS ...

最新文章

  1. 服务器插显示器黑的,服务器插显示器不显示
  2. NBT:超高速细菌基因组检索技术
  3. R语言officer、flextable包生成word报告
  4. 数据结构——树、森林和二叉树之间的转换
  5. mysql从zip包安装小记
  6. Java中List排序的3种方法!
  7. 【成功不是等来的】生意不好问人不如问己!谈真实经验!
  8. 抢票加速包的钱都白花了?铁总:第三方抢票软件已被限制
  9. 【Flink】Flink Committing offsets to Kafka takes longer than the checkpoint interval
  10. PostgreSQL | 学习笔记语句汇总
  11. Java面试题全集中
  12. pdf文件如何生成目录 wps_WPS中如何自动生成目录
  13. C++ 判断矩形是否相交
  14. mysql 分库分表实战_DBLE分库分表实战
  15. 李智慧 - 架构师训练营 第二周
  16. CloudDrive — 将阿里云盘变成电脑本地磁盘,网盘挂载映射为本地磁盘!
  17. 计算机专业参赛口号,参赛口号
  18. Android github上优秀开源项目分类汇总
  19. Gamma Correction/Gamma校正/灰度校正/亮度校正(已更正) - 部分 DCC 中的线性工作流配置
  20. 中国教育信息化行业发展价值分析与运营前景展望报告2022版

热门文章

  1. 字符串还可以这样初始化--uboot篇
  2. XShell连接Deepin
  3. Windows上安装Nacos
  4. 无盘工作站 服务器 性能,无盘工作站与有盘工作站比较,突出的优势有哪些?...
  5. C/C++、嵌入式开发岗笔试集锦
  6. 力扣—— 三维形体投影面积
  7. iOS开发实战-基于SpriteKit的FlappyBird小游戏
  8. 【转】学习汇编前你应该知道的知识
  9. Java线程安全 关于原子性与volatile的试验
  10. MongoDB安装指南