百度charts_NBA Shot Charts:更新

百度charts

For some reason I recently got it in my head that I wanted to go back and create more NBA shot charts. My previous shotcharts used colored circles to depict the frequency and effectiveness of shots at different locations. This is an extremely efficient method of representing shooting profiles, but I thought it would be fun to create shot charts that represent a player’s shooting profile continously across the court rather than in discrete hexagons.

由于某种原因,我最近想起要创建更多的NBA投篮记录。 我以前的弹图使用彩色圆圈描绘了不同位置的拍摄频率和效果。 这是表示射击轮廓的一种非常有效的方法,但是我认为创建一个能够在球场上连续而不是离散的六边形来表示球员的射击轮廓的射击图表会很有趣。

By depicting the shooting data continously, I lose the ability to represent one dimenion – I can no longer use the size of circles to depict shot frequency at a location. Nonetheless, I thought it would be fun to create these charts.

通过连续描绘拍摄数据,我失去了表示一个维度的能力–我再也无法使用圆圈的大小来描绘某个位置的拍摄频率。 尽管如此,我认为创建这些图表会很有趣。

I explain how to create them below. I’ve also included the ability to compare a player’s shooting performance to the league average.

我在下面解释如何创建它们。 我还包括了将球员的投篮表现与联盟平均水平进行比较的功能。

In my previous shot charts, I query nba.com’s API when creating a players shot chart, but querying nba.com’s API for every shot taken in 2015-16 takes a little while (for computing league average), so I’ve uploaded this data to my github and call the league data as a file rather than querying nba.com API.

在我以前的击球图中,我在创建球员击球图时查询nba.com的API,但是对于2015-16赛季的每一次击球,查询nba.com的API都需要花费一些时间(用于计算联盟平均水平),因此我已经上传了此数据数据发送到我的github,然后将联赛数据作为文件调用,而不是查询nba.com API。

This code is also available as a jupyter notebook on my github.

此代码也可以在我的github上作为jupyter笔记本使用。

1
1
2
2
3
3

Here, I create a function for querying shooting data from NBA.com’s API. This is the same function I used in my previous post regarding shot charts.

在这里,我创建了一个用于从NBA.com的API查询射击数据的函数。 这与我以前的关于击球图表的帖子中使用的功能相同。

You can find a player’s ID number by going to the players nba.com page and looking at the page address. There is a python library that you can use for querying player IDs (and other data from the nba.com API), but I’ve found this library to be a little shaky.

您可以转到播放器nba.com页面并查看页面地址来找到播放器的ID号。 有一个python库可用于查询播放器ID(以及nba.com API中的其他数据),但是我发现该库有些不稳定。

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25

Create a function for drawing the nba court. This function was taken directly from Savvas Tjortjoglou’s post on shot charts.

创建一个用于绘制nba球场的函数。 该功能直接取自Savvas Tjortjoglou在击球图表上的帖子

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42

Write a function for acquiring each player’s picture. This isn’t essential, but it makes things look nicer. This function takes a playerID number and the amount to zoom in on an image as the inputs. It by default places the image at the location 500,500.

编写获取每个玩家照片的功能。 这不是必需的,但可以使事情看起来更好。 此功能将玩家ID号和放大图像的数量作为输入。 默认情况下,它将图像放置在500,500的位置。

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9

Here is where things get a little complicated. Below I write a function that divides the shooting data into a 25×25 matrix. Each shot taken within the xy coordinates encompassed by a given bin counts towards the shot count in that bin. In this way, the method I am using here is very similar to my previous hexbins (circles). So the difference just comes down to I present the data rather than how I preprocess it.

这是事情变得有些复杂的地方。 在下面,我写了一个函数,将拍摄数据分为25×25矩阵。 给定仓位所包含的xy坐标内拍摄的每个镜头都计入该仓位中的镜头数量。 这样,我在这里使用的方法与我以前的六边形(圆圈)非常相似。 因此,区别只在于我呈现数据而不是预处理数据。

This function takes a dataframe with a vector of shot locations in the X plane, a vector with shot locations in the Y plane, a vector with shot type (2 pointer or 3 pointer), and a vector with ones for made shots and zeros for missed shots. The function by default bins the data into a 25×25 matrix, but the number of bins is editable. The 25×25 bins are then expanded to encompass a 500×500 space.

此函数获取一个数据帧,该数据帧的X平面上具有射击位置矢量,Y平面上具有射击位置矢量,一个具有射击类型(2指针或3指针)的矢量以及一个带有1的已拍摄镜头和零的向量错过了镜头。 默认情况下,该功能将数据合并到25×25矩阵中,但是合并数是可编辑的。 然后将25×25的箱扩展为包含500×500的空间。

The output is a dictionary containing matrices for shots made, attempted, and points scored in each bin location. The dictionary also has the player’s ID number.

输出是一个字典,其中包含用于在每个仓位中拍摄,尝试和得分的矩阵。 字典中也有玩家的ID号。

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29

Below I load the league average data. I also have the code that I used to originally download the data and to preprocess it.

下面我加载联盟平均数据。 我还拥有用于最初下载数据和对其进行预处理的代码。

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9

I really like playing with the different color maps, so here is a new color map I created for these shot charts.

我真的很喜欢玩不同的颜色表,因此这里是我为这些拍摄图表创建的新颜色表。

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15

Below, I write a function for creating the nba shot charts. The function takes a dictionary with martrices for shots attempted, made, and points scored. The matrices should be 500×500. By default, the shot chart depicts the number of shots taken across locations, but it can also depict the number of shots made, field goal percentage, and point scored across locations.

在下面,我编写了一个用于创建nba击球图的函数。 该功能采用字典,其中包含尝试,做出和得分的矩阵。 矩阵应为500×500。 默认情况下,击球图描述的是不同地点拍摄的照片数量,但它也可以描述不同地点拍摄的照片数量,射门得分百分比和得分。

The function uses a gaussian kernel with standard deviation of 5 to smooth the data (make it look pretty). Again, this is editable. By default the function plots a players raw data, but it will plot how a player compares to league average if the input includes a matrix of league average data.

该函数使用标准偏差为5的高斯核来平滑数据(使其看起来很漂亮)。 同样,这是可编辑的。 默认情况下,该函数绘制球员原始数据,但是如果输入包含联赛平均值数据矩阵,它将绘制玩家与联赛平均值的比较关系。

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
49
50
50
51
51
52
52
53
53
54
54
55
55
56
56
57
57
58
58
59
59
60
60
61
61
62
62
63
63
64
64
65
65
66
66
67
67
68
68
69
69
70
70

Alright, thats that. Now lets create some plots. I am a t-wolves fan, so I will plot data from Karl Anthony Towns.

好的,就是这样。 现在让我们创建一些图。 我是T型狼迷,所以我将绘制Karl Anthony Towns的数据。

First, here is the default plot – attempts.

首先,这是默认绘图-尝试次数。

1
1
2
2
3
3

Here’s KAT’s shots made

这是KAT的镜头

1
1
2
2
3
3

Here’s field goal percentage. I don’t like this one too much. It’s hard to use similar scales for attempts and field goal percentage even though I’m using standard deviations rather than absolute scales.

这是射门得分百分比。 我不太喜欢这个。 即使我使用标准差而不是绝对比例,也很难对尝试和射门得分百分比使用相似的比例。

1
1
2
2
3
3

Here’s points across the court.

这是整个球场上的要点。

1
1
2
2
3
3

Here’s how KAT’s attempts compare to the league average. You can see the twolve’s midrange heavy offense.

这是KAT的尝试与联盟平均值进行比较的方式。 您可以看到Twolve的中距离进攻。

1
1
2
2
3
3

How KAT’s shots made compares to league average.

KAT的投篮方式与联盟平均水平相比。

1
1
2
2
3
3

How KAT’s field goal percentage compares to league average. Again, the scale on these is not too good.

KAT的投篮命中率与联盟平均值的比较。 同样,这些方面的规模还不太好。

1
1
2
2
3
3

And here is how KAT’s points compare to league average.

这是KAT的积分与联盟平均值的比较。

1
1
2
2
3
3

翻译自: https://www.pybloggers.com/2016/05/nba-shot-charts-updated/

百度charts

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值