I have now made a significant update to my applied machine learning paper on predicting patterns among NBA playoff and championship teams, which can be accessed here: arXiv Link .
Tag: Analytics
The Most Optimal Strategy for the Knicks
In a previous article, I showed how one could use data in combination with advanced probability techniques to determine the optimal shot / court positions for LeBron James. I decided to use this algorithm on the Knicks’ starting 5, and obtained the following joint probability density contour plots:
One sees that the Knicks offensive strategy is optimal if and only if players gets shots as close to the basket as possible. If this is the case, the players have a high probability of making shots even if defenders are playing them tightly. This means that the Knicks would be served best by driving in the paint, posting up, and Porzingis NOT attempting a multitude of three point shots.
By the way, a lot of people are convinced nowadays that someone like Porzingis attempting 3’s is a sign of a good offense, as it is an optimal way to space the floor. I am not convinced of this. Spacing the floor geometrically translates to a multi-objective nonlinear optimization problem. In particular, let represent the (x-y)-coordinates of a player on the floor. Spreading the floor means one must maximize (simultaneously) each element of the following distance metric:
subject to . While a player attempting 3-point shots may be one way to solve this problem, I am not convinced that it is a unique solution to this optimization problem. In fact, I am convinced that there are a multiple of solutions to this optimization problem.
This solution is slightly simpler if one realizes that the metric above is symmetric, so that there are only 11 independent components.
Analyzing Lebron James’ Offensive Play
Where is Lebron James most effective on the court?
Based on 2015-2016 data, we obtained from NBA.com the following data which tracks Lebron’s FG% based on defender distance:
From Basketball-Reference.com, we then obtained data of Lebron’s FG% based on his shot distance from the basket:
Based on this data, we generated tens of thousands of sample data points to perform a Monte Carlo simulation to obtain relevant probability density functions. We found that the joint PDF was a very lengthy expression(!):
Graphically, this is:
A contour plot of the joint PDF was computed to be:
From this information, we can compute where/when LeBron has the highest probability of making a shot. Numerically, we found that the maximum probability occurs when Lebron’s defender is 0.829988 feet away, while Lebron is 1.59378 feet away from the basket. What is interesting is that this analysis shows that defending Lebron tightly doesn’t seem to be an effective strategy if his shot distance is within 5 feet of the basket. It is only an effective strategy further than 5 feet away from the basket. Therefore, opposing teams have the best chance at stopping Lebron from scoring by playing him tightly and forcing him as far away from the basket as possible.
Breaking Down the 2015-2016 NBA Season
In this article, I will use Data Science / Machine Learning methodologies to break down the real factors separating the playoff from non-playoff teams. In particular, I used the data from Basketball-Reference.com to associate 44 predictor variables which each team: “FG” “FGA” “FG.” “X3P” “X3PA” “X3P.” “X2P” “X2PA” “X2P.” “FT” “FTA” “FT.” “ORB” “DRB” “TRB” “AST” “STL” “BLK” “TOV” “PF” “PTS” “PS.G” “oFG” “oFGA” “oFG.” “o3P” “o3PA” “o3P.” “o2P” “o2PA” “o2P.” “oFT” “oFTA” “oFT.” “oORB” “oDRB” “oTRB” “oAST” “oSTL” “oBLK” “oTOV” “oPF” “oPTS” “oPS.G”
, where a letter ‘o’ before the last 22 predictor variables indicates a defensive variable. (‘o’ stands for opponent. )
Using principal components analysis (PCA), I was able to project this 44-dimensional data set to a 5-D dimensional data set. That is, the first 5 principal components were found to explain 85% of the variance.
Here are the various biplots:
In these plots, the teams are grouped according to whether they made the playoffs or not.
One sees from this biplot of the first two principal components that the dominant component along the first PC is 3 point attempts, while the dominant component along the second PC is opponent points. CLE and TOR have a high negative score along the second PC indicating a strong defensive performance. Indeed, one suspects that the final separating factor that led CLE to the championship was their defensive play as opposed to 3-point shooting which all-in-all didn’t do GSW any favours. This is in line with some of my previous analyses.
Optimal Positions for NBA Players
I was thinking about how one can use the NBA’s new SportVU system to figure out optimal positions for players on the court. One of the interesting things about the SportVU system is that it tracks player coordinates on the court. Presumably, it also keeps track of whether or not a player located at makes a shot or misses it. Let us denote a player making a shot by , and a player missing a shot by . Then, one essentially will have data in the form .
One can then use a logistic regression to determine the probability that a player at position will make a shot:
The main idea is that the parameters uniquely characterize a given player’s probability of making a shot.
As a coaching staff from an offensive perspective, let us say we wish to position players as to say they have a very high probability of making a shot, let us say, for demonstration purposes 99%. This means we must solve the optimization problem:
(The constraints are determined here by the x-y dimensions of a standard NBA court).
This has the following solutions:
with the following conditions:
One can also have:
with the following conditions:
Another solution is:
with the following conditions:
The fourth possible solution is:
with the following conditions:
In practice, it should be noted, that it is typically unlikely to have a player that has a 99% probability of making a shot.
To put this example in more practical terms, I generated some random data (1000 points) for a player in terms of coordinates and whether he made a shot from that distance or not. The following scatter plot shows the result of this simulation:
In this plot, the red dots indicate a player has made a shot (a response of 1.0) from the coordinates given, while a purple dot indicates a player has missed a shot from the coordinates given (a response of 0.0).
Performing a logistic regression on this data, we obtain that .
Using the equations above, we see that this player has a maximum probability of of making a shot from a location of , and a minimum probability of of making a shot from a location of .
Optimal Strategies for the Clinton/Trump Debate
Consider modelling the Clinton/Trump debate via a static game in which each candidate can choose between two strategies: , where denotes predominantly “attacking” the other candidate, while denotes predominantly discussing policy positions.
Further, let us consider the mixed strategies for Clinton, and for Trump. That is, Clinton predominantly attacks Trump with probability , and Trump predominantly attacks Clinton with probability .
Let us first deal with the general case of arbitrary payoffs, thus, generating the following payoff matrix:
That is, if Clinton attacks Trump and Trump attacks Clinton, the payoff to Clinton is , while the payoff to Trump is . If Clinton attacks Trump, and Trump ignores and discusses policy positions instead, the payoff to Clinton is , while the payoff to trump is . If Clinton discusses policy positions while Trump attacks, the payoff to Clinton is , while the payoff to Trump is , and if both candidates discuss policy positions instead of attacking each other, the payoff to them both will be and respectively.
With this information in hand, we can calculate the payoff to Clinton as:
while the payoff to Trump is:
With these payoff functions, we can compute each candidate’s best response to the other candidate by solving the following equations:
where indicates the best response strategy to a fixed strategy for the other player.
Solving these equations, we obtain the following:
If
then,
Clinton’s best response is to choose .
If
then,
Clinton’s best response is to choose .
Otherwise, her best response is to choose .
While for Trump, the best responses are computed as follows:
If
Trump’s best response is to choose .
If
Trump’s best response is to choose .
Otherwise, Trump’s best response is to choose .
To demonstrate this, let us work out an example. Assume (for this example) that the payoffs for each candidate are to sway independent voters / voters that have not made up their minds. Further, let us assume that these voters are more interested in policy positions, and will take attacks negatively. Obviously, this is not necessarily true, and we have solved the general case above. We are just using the following payoff matrix for demonstration purposes:
Using the above equations, we see that if , Clinton’s best response is to choose . While, if , Trump’s best response is to choose . That is, no matter what Trump’s strategy is, it is always Clinton’s best response to discuss policy positions. No matter what Clinton’s strategy is, it is always Trump’s best response to discuss policy positions as well. The two candidates’ payoff functions take the following form:
What this shows for example is that there is a Nash equilibrium of:
.
The expected payoffs for each candidate are evidently
.
Let us work out an another example. This time, assume that if Clinton attacks Trump, she receives a payoff of , while if Trump attacks Clinton, he receives a payoff of . While, if Clinton discusses policy, while being attacked by Trump, she receives a payoff of , while Trump receives a payoff of . On the other hand, if Trump discusses policy while being attacked by Clinton, he receives a payoff , while Clinton receives a payoff of . If Clinton discusses policy, while Trump discusses policy, she receives a payoff of , while Trump receives a payoff of . The payoff matrix is evidently:
In this case, if , then Clinton’s best response is to choose . While, if , then Trump’s best response is to choose . The Nash equilibrium is evidently
.
The expected payoffs for each candidate are evidently
.
In this example, even though it is the optimal strategy for each candidate to play a mixed strategy of 50% attack, 50% discuss policy, Clinton is expected to benefit, while Trump is expected to lose.
Let us also consider an example of where the audience is biased towards Trump. So, every time Trump attacks Clinton, he gains an additional point. Every time Trump discusses policy, while Clinton does the same he gains an additional point. While, if Clinton attacks while Trump discusses policy positions, she will lose a point, and he gains a point. Such a payoff matrix can be given by:
Solving the equations above, we find that if , Clinton’s best response is to choose . If , Clinton’s best response is to choose . Otherwise, her best response is to choose . On the other hand, if , Trump’s best response is to choose . While, if , Trump’s best response is to choose . Evidently, there is a single Nash equilibrium (as long as ):
.
Therefore, in this situation, it is each candidate’s best strategy to attack one another. It is interesting that even in an audience that is heavily biased towards Trump, Clinton’s best strategy is still to attack 100% of the time.
The interested reader is invited to experiment with different scenarios using the general results derived above.
Will Donald Trump’s Proposed Immigration Policies Curb Terrorism in The US?
In recent days, Donald Trump proposed yet another iteration of his immigration policy which is focused on “Keeping America Safe” as part of his plan to “Make America Great Again!”. In this latest iteration, in addition to suspending visas from countries with terrorist ties, he is also proposing introducing an ideological test for those entering the US. As you can see in the BBC article, he is also fond of holding up bar graphs of showing the number of refugees entering the US over a period of time, and somehow relates that to terrorist activities in the US, or at least, insinuates it.
Let’s look at the facts behind these proposals using the available data from 2005-2014. Specifically, we analyzed:
- The number of terrorist incidents per year from 2005-2014 from here (The Global Terrorism Database maintained by The University of Maryland)
- The Department of Homeland Security Yearbook of Immigration Statistics, available here . Specifically, we looked at Persons Obtaining Lawful Permanent Resident Status by Region and Country of Birth (2005-2014) and Refugee Arrivals by Region and Country of Nationality (2005-2014).
Given these datasets, we focused on countries/regions labeled as terrorist safe havens and state sponsors of terror based on the criteria outlined here .
We found the following.
First, looking at naturalized citizens, these computations yielded:
Country |
Correlations |
Percent of Variance Explained |
Afghanistan |
0.61169 |
0.37416 |
Egypt |
0.26597 |
0.07074 |
Indonesia |
-0.66011 |
0.43574 |
Iran |
-0.31944 |
0.10204 |
Iraq |
0.26692 |
0.07125 |
Lebanon |
-0.35645 |
0.12706 |
Libya |
0.59748 |
0.35698 |
Malaysia |
0.39481 |
0.15587 |
Mali |
0.20195 |
0.04079 |
Pakistan |
0.00513 |
0.00003 |
Phillipines |
-0.79093 |
0.62557 |
Somalia |
-0.40675 |
0.16544 |
Syria |
0.62556 |
0.39132 |
Yemen |
-0.11707 |
0.01371 |
In graphical form:
The highest correlations are 0.62556 and 0.61669 from Syria and Afghanistan respectively. The highest anti-correlations were from Indonesia and The Phillipines at -0.66011 and -0.79093 respectively. Certainly, none of the correlations exceed 0.65, which indicates that there could be some relationship between the number of naturalized citizens from these particular countries and the number of terrorist incidents, but, it is nowhere near conclusive. Further, looking at Syria, we see that the percentage of variance explained / coefficient of determination is 0.39132, which means that only about 39% of the variation in the number of terrorist incidents can be predicted from the relationship between where a naturalized citizen is born and the number of terrorist incidents in The United States.
Second, looking at refugees, these computations yielded:
Country |
Correlations |
Percent of Variance Explained |
Afghanistan |
0.59836 |
0.35803 |
Egypt |
0.66657 |
0.44432 |
Iran |
-0.29401 |
0.08644 |
Iraq |
0.49295 |
0.24300 |
Pakistan |
0.60343 |
0.36413 |
Somalia |
0.14914 |
0.02224 |
Syria |
0.56384 |
0.31792 |
Yemen |
-0.35438 |
0.12558 |
Other |
0.54109 |
0.29278 |
In graphical form:
We see that the highest correlations are from Egypt (0.6657), Pakistan (0.60343), and Afghanistan (0.59836). This indicates there is some mild correlation between refugees from these countries and the number of terrorist incidents in The United States, but it is nowhere near conclusive. Further, the coefficients of determination from Egypt and Syria are 0.44432 and 0.31792 respectively. This means that in the case of Syrian refugees for example, only 31.792% of the variation in terrorist incidents in the United States can be predicted from the relationship between a refugee’s country of origin and the number of terrorist incidents in The United States.
In conclusion, it is therefore unlikely that Donald Trump’s proposals would do anything to significantly curb the number of terrorist incidents in The United States. Further, repeatedly showing pictures like this:
at his rallies is doing nothing to address the issue at hand and is perhaps only serving as yet another fear tactic as has become all too common in his campaign thus far.
(Thanks to Hargun Singh Kohli, Honours B.A., LL.B. for the initial data mining and processing of the various datasets listed above.)
Note, further to the results of this article, I was recently made aware of this excellent article from The WSJ, which I have summarized below: