![]() That’s because we’re analyzing the data from the perspective of the home team. Strictly speaking we’re only observing the variables’ correlation.Īlso notice that intercept is clearly non-zero. Although turnovers almost certainly cause a change in the final score, it would be overstating the capabilities of our methods. This means each turnover is worth about 4.5 points to the final score margin.īe careful not to interpret it as a causal relationship. If you print slope and intercept values you’ll find: slope = 4.53 Pass the appropriate dataframe columns into (): slope, intercept, r_value, p_value, std_err = linregress(df, We’ll use it to calculate R², which essentially tells us how tightly data points fit the regression line.This is r, the correlation coefficient.The y-intercept of the regression line.The slope (rise over run) of the regression line.This function returns five values but we’re interested in three: Doing regressions by hand is extremely tedious, but with Python it’s as easy as passing two iterables into (). Now it’s time to perform a simple linear regression. Limiting analysis to the most recent decade, while not perfect, should better represent the modern game while still providing plenty of data points. Football fans know how much the sport has changed throughout its history. df.loc = df - dfĭf.loc = df - dfĪfter that, restrict the dataframe to the most recent 10 years of games. This helps us avoid double-counting games!Ĭreate two new columns to contain said variables. Notice we’ve arbitrarily decided to work from the perspective of the home team. Since we’re interested in calculating how turnovers affect the final score, we’ll set up the regression like this: Get started by reading the dataset and converting its date column to datetime format. It contains team stats from every NFL game going back to 2002. The dataset can be downloaded from Kaggle. Making a new appearance is SciPy, a powerful and extensive Python library for scientific computing. We’ve worked with pandas and Matplotlib many times on the blog. How often teams win when they earn a turnover advantage.Īnd of course we’ll plot the regression line.īegin with the imports.How many points each turnover is worth, on average.And few advantages pack a punch like turnovers, which occur when one team takes the ball away from the other.Įxactly how much do turnovers matter? We can find out by utilizing simple linear regression. I’ve always taken that to mean that many seemingly small edges are actually crucial to the final score. ![]() ![]() Let’s continue the streak of sports posts!įootball-that’s American football, not soccer-is often characterized as a game of inches. The 2021-22 NFL season kicked off last night and I’m in a football mood. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |