足球预测

By Aditya Pethe

通过阿蒂亚·皮特(Aditya Pethe)

From September to January every year, football takes over America. Games dominate TV Sunday and Monday nights, and my brother tears his hair out each week over his consistently underperforming fantasy teams. The hype seems to reach an unbearable level by the time the playoffs roll around.

每年的9月至1月,足球席卷美国。 游戏在星期日和星期一晚上占据着电视台的主导地位,而我的兄弟每周都在表现不佳的幻想队中大放异彩。 季后赛到来之时,炒作似乎已经到了难以忍受的地步。

But is there a way to measure and forecast that hype? I decided to use one of my favorite NFL players, Peyton Manning, in order to explore seasonality in Deephaven’s Jupyter Notebooks. Using a dataset of Manning’s Wikipedia search frequencies taken over an 8 year period from 2008 to 2016, my goal was to break down how football hype evolved throughout the season.

但是,有没有一种方法可以衡量和预测这种炒作? 我决定使用我最喜欢的NFL球员之一Peyton Manning来探索Deephaven的Jupyter笔记本的季节性。 使用从2008年到2016年的8年期间内Manning的Wikipedia搜索频率的数据集 ,我的目标是弄清整个赛季足球宣传的演变。

To do this, I decided to take two approaches to analyzing seasonality. The first was the traditional ARIMA model, and the second was the newer Fbprophet library. I would use both these methods to fit, predict, and validate models to see which was better at understanding NFL hype.

为此,我决定采用两种方法来分析季节性。 第一个是传统的ARIMA模型,第二个是较新的Fbprophet库。 我将使用这两种方法来拟合,预测和验证模型,以查看哪种方法更适合理解NFL宣传。

我们的数据 (OUR DATA)

We can plot our data in Deephaven with the following code:

我们可以使用以下代码在Deephaven中绘制数据:

At a top-level glance, our data is log-transformed Wikipedia page views for Peyton Manning taken each day for about 8 years. The data appears to exhibit some strong seasonal trends that we can look into.

从最高层次看,我们的数据是对Peyton Manning进行日志转换的Wikipedia页面视图,大约每天进行8年。 数据似乎显示出一些我们可以研究的强烈季节性趋势。

Additionally, before we begin breaking down our data, we want a consistent way to visualize our forecasts. We can produce a function that takes our training, testing, and any forecast data and plots it with Deephaven. This allows us to combine analysis from multiple libraries and methods with Deephaven’s powerful and interactive plotting.

此外,在开始分解数据之前,我们需要一种一致的方式来可视化我们的预测。 我们可以产生一个函数,将我们的训练,测试和所有预测数据都用Deephaven进行绘制。 这使我们能够将来自多个库和方法的分析与Deephaven强大而交互式的绘图相结合。

有马 (ARIMA)

The ARIMA model stands for autoregressive, integrated moving average model.

ARIMA模型代表自回归,集成移动平均模型。

The Autoregressive, or AR component of the model, is a linear combination of the previous N seasonal lags. For our Peyton Manning model, this means some linear combination of the previous N weeks, months, or years.

模型的自回归或AR分量是前N个季节滞后的线性组合。 对于我们的Peyton Manning模型,这意味着前N周,几个月或几年的线性组合。

The moving average component of the model is a linear combination of the error terms for the previous N seasonal lags, like so:

模型的移动平均成分是前N个季节滞后的误差项的线性组合,如下所示:

The ARIMA model will estimate the coefficients for both these linear combinations, given three parameters as input:

给定三个参数作为输入,ARIMA模型将估算这两个线性组合的系数:

  • p: The order of the autoregressive model (the number of lagged terms), described in the AR equation above.

    p:自回归模型的顺序(滞后项的数量),在上面的AR方程中描述。

  • q: The order of the moving average model (the number of lagged terms), described in the MA equation above.

    q:移动平均模型的阶数(滞后项的数量),如上面的MA方程所述。

  • d: The number of differences required to make the time series stationary. A stationary time series is essentially a time series without a time-dependent trend, excluding the seasonality.

    d:使时间序列固定所需的差数。 固定时间序列本质上是没有季节性相关趋势的时间序列,不包括季节性。

In the example below, the blue time series would be considered stationary, while the red would be nonstationary, even though both may exhibit seasonal patterns.

在下面的示例中,蓝色时间序列将被认为是平稳的,而红色时间序列将被视为非平稳的,即使这两个时间序列都可能呈现季节性变化。

Now that we know what parameters we need to find, we can analyze our Peyton Manning data. At first glance, our data seems stationary. There doesn’t appear to be a time-dependent trend outside seasonal fluctuations, but we can test for this using the Augmented Dickey-Fuller Test.

既然我们知道需要找到什么参数,就可以分析Peyton Manning数据。 乍一看,我们的数据似乎稳定。 除季节性波动外,似乎没有随时间变化的趋势,但是我们可以使用增强Dickey-Fuller检验进行检验。

Our test returns a p-value well below the significance level, so we can confirm that our model is indeed stationary. Our parameter value for d is zero.

我们的测试返回的p值远低于显着性水平,因此我们可以确认我们的模型确实是平稳的。 d的参数值为零。

Now we need to find the parameter values of P and Q. In order to do this, I used autocorrelation plots. Autocorrelation and partial autocorrelation plots can tell how strongly lagged terms correlated with a given observation. While partial autocorrelation plots tell the correlation with the lag term independent of other lags, autocorrelation plots factor in the “inertia” from other lags. Because of this, we can use partial autocorrelation to estimate our parameter for P, and autocorrelation to estimate our parameter for Q.

现在我们需要找到P和Q的参数值。为此,我使用了自相关图。 自相关图和局部自相关图可以说明滞后项与给定观察值的相关程度。 尽管部分自相关图告诉了与滞后项的相关性,而与其他滞后无关,但自相关图将其他滞后的“惯性”作为因素。 因此,我们可以使用偏自相关来估计P的参数,并使用自相关来估计Q的参数。

Both plots show a periodic behavior in the lags, each around 7 days in length. This makes sense — Peyton Manning search frequency probably increases on game nights, when football is being played. In fact, these autocorrelation plots even show a slight 6-day correlation, which is likely due to Sunday night football. But since the lags of 7 days have the highest correlation with the observed value, we can estimate both P and Q to be 7.

这两个图都显示了滞后的周期性行为,每个周期的长度约为7天。 这是有道理的-在踢足球的比赛之夜,佩顿·曼宁的搜索频率可能会增加。 实际上,这些自相关图甚至显示了轻微的6天相关性,这很可能是由于周日晚上的足球比赛所致。 但是由于7天的滞后与观测值具有最高的相关性,因此我们可以估计P和Q均为7。

I should note that these autocorrelation plots presented a problem. The ARIMA parameters did not allow for lag inputs of over ~10, which meant that looking at annual (365) or monthly (30) seasonality would be very difficult.

我应该注意,这些自相关图存在问题。 ARIMA参数不允许滞后输入超过〜10,这意味着查看年度(365)或每月(30)的季节性非常困难。

Now that we have our parameters, we can produce our ARIMA model.

现在我们有了参数,我们可以生成ARIMA模型。

Before we make our forecasts, we can check our model assumptions for variance and normality with a residual plot and density plot.

在进行预测之前,我们可以使用残差图和密度图检查模型假设的方差和正态性。

Since the residuals appear to be randomly distributed, and the kernel probability density plot appears normal, our model assumptions check out.

由于残差似乎是随机分布的,并且核概率密度图似乎是正态的,因此我们的模型假设得到了检验。

Plotting our model yields the following:

绘制模型将得出以下结果:

As we can see, not having access to the other scales of seasonality hurts this model’s viability. Not being able to capture multiple seasonal trends means that ARIMA is limited by one seasonality at a time. Regardless, we can return some error estimators to validate our model.

如我们所见,无法使用其他季节性尺度会损害该模型的生存能力。 无法捕获多个季节趋势意味着ARIMA一次只能受到一个季节的限制。 无论如何,我们可以返回一些误差估计量来验证我们的模型。

  • MSE (mean squared error): 0.8916776825661407

    MSE (均方误差):0.8916776825661407

  • MAPE (mean absolute percentage error): 0.10230290573107942

    MAPE (平均绝对百分比误差):0.10230290573107942

萨里玛 (SARIMA)

We can actually validate our ARIMA model using the auto-SARIMA model from pmdarima. The auto-SARIMA model estimates the parameter values for p, q, and d for us so there is no need for the prelude above. In addition, SARIMA takes m, the period of seasonality, as a parameter. Unfortunately, the model parameter limitations again constrain us to m < 10, so we may only look at weekly seasonality.

实际上,我们可以使用pmdarima的auto-SARIMA模型验证ARIMA模型。 auto-SARIMA模型为我们估计pqd的参数值,因此不需要上面的前奏。 另外,SARIMA将季节周期m用作参数。 不幸的是,模型参数限制再次将我们限制为m <10 ,因此我们可能只查看每周的季节性。

Fitting and plotting our model gives us the following:

拟合和绘制模型可以得到以下结果:

Lastly, we can validate our model with error metrics:

最后,我们可以使用错误指标来验证我们的模型:

  • MSE (mean squared error): 0.8916776825661407

    MSE (均方误差):0.8916776825661407

  • MAPE (mean absolute percentage error): 0.10789283997956421

    MAPE (平均绝对百分比误差):0.10789283997956421

We see that our SARIMA model performed nearly identically to our ARIMA model, and in fact our ARIMA model gave a slightly lower mean absolute percentage error than SARIMA. We can be happy that we picked optimal parameters to fit our ARIMA model with.

我们看到,SARIMA模型的性能几乎与ARIMA模型相同,并且实际上,ARIMA模型的平均绝对百分比误差略低于SARIMA。 我们很高兴选择了适合ARIMA模型的最佳参数。

预言家 (PROPHET)

For our final model, we will be using Fbprophet.

对于我们的最终模型,我们将使用Fbprophet。

Fbprophet is a library from Facebook intended to handle seasonal time-series datasets. Prophet implements a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. In general, using Prophet requires much less hands-on work than our ARIMA model, and for the most part, we can feed our data directly into prophet like so:

Fbprophet是Facebook的一个库,用于处理季节性时间序列数据集。 先知实现了一种基于加性模型的时间序列数据预测程序,其中非线性趋势与年,周和日的季节性以及假期效应相吻合。 通常,与我们的ARIMA模型相比,使用Prophet所需的动手工作少得多,并且在大多数情况下,我们可以像这样将数据直接输入到先知中:

This allows us to forecast one year ahead, and compare actual data with expected values and their boundaries.

这使我们可以预测一年,并将实际数据与期望值及其界限进行比较。

In addition, Prophet allows us to break down this data into seasonal components:

此外,先知使我们可以将这些数据分解为季节性成分:

Manning’s page views peaked in 2012–2013, his MVP year. Unsurprisingly, Monday night football is when most fans look Manning up, and the monthly seasonal breakdown shows the crazy highs of December and March in stark contrast to the great drought of the summer.

曼宁的网页浏览量在他的MVP年度(2012-2013)达到顶峰。 毫不奇怪,周一晚上的足球比赛是大多数球迷抬头看曼宁的时候,每月的季节性故障显示出12月和3月的疯狂高点,与夏季的干旱形成鲜明对比。

Prophet can do even more, and add changepoints to the data, where the trend is most likely to shift.

先知可以做更多的事情,并且可以向数据添加变化点,而趋势最有可能在此变化。

With this feature, Prophet roughly estimates the start and end of the season, especially capturing the window of the playoffs.

通过此功能,先知大致估计了赛季的开始和结束,尤其是捕获了季后赛的窗口。

By the eye test alone, our prophet models look much better and coherent than ARIMA. But we can again validate the model predictions using MSE and MAPE.

仅凭眼睛测试,我们的先知模型看上去比ARIMA更好,更连贯。 但是我们可以再次使用MSE和MAPE验证模型预测。

  • MSE (mean squared error): 0.35800021765342394

    MSE (均方误差):0.35800021765342394

  • MAPE (mean absolute percentage error): 0.059460265364126956

    MAPE (平均绝对百分比误差):0.059460265364126956

结论 (CONCLUSION)

Both error estimators clearly point to Prophet as the more accurate model. For large time-series data with multiple seasonalities, ARIMA has many shortcomings. Simply using regression on previous lags to estimate future values won’t cut it in predicting more complex time-series datasets. ARIMA may be useful for more limited datasets with simpler seasonal effects, but particularly for things like sensor data, page views, or energy consumption, complex nonlinear models like Prophet are required to make predictions.

两种误差估计器都明确指出先知是更准确的模型。 对于具有多个季节性的大型时间序列数据,ARIMA有许多缺点。 只需对先前的滞后使用回归来估计未来值,就无法预测更复杂的时间序列数据集。 ARIMA可能对于季节效应较为简单的有限数据集很有用,但是对于传感器数据,页面浏览量或能源消耗之类的东西尤其如此,需要使用诸如Prophet之类的复杂非线性模型进行预测。

Deephaven’s integration with Jupyter Notebooks allows for users to have unique, library-specific plotting methods and operations side by side with Deephaven features. Deephaven’s plotting in particular provides user-friendly visualization options in interactive plots when used in conjunction with new, cutting edge libraries like fbprophet.

Deephaven与Jupyter Notebooks的集成使用户可以与Deephaven功能并排使用独特的,特定于库的绘图方法和操作。 当与新的尖端库(例如fbprophet)结合使用时,Deephaven的绘图在交互式绘图中尤其提供了用户友好的可视化选项。

翻译自: https://medium.com/dev-genius/forecasting-football-fever-fe46fa779b69

足球预测


http://www.taodudu.cc/news/show-994975.html

相关文章:

  • python3中朴素贝叶斯_贝叶斯统计:Python中从零开始的都会都市
  • 数据治理 主数据 元数据_我们对数据治理的误解
  • 提高机器学习质量的想法_如何提高机器学习的数据质量?
  • 逻辑回归 python_深入研究Python的逻辑回归
  • Matplotlib中的“ plt”和“ ax”到底是什么?
  • cayenne:用于随机模拟的Python包
  • spotify 数据分析_没有数据? 没问题! 如何从Wikipedia和Spotify收集重金属数据
  • kaggle数据集_Kaggle上有170万份ArXiv文章的数据集
  • 深度学习数据集中数据差异大_使用差异隐私来利用大数据并保留隐私
  • 小型数据库_如果您从事“小型科学”工作,那么您是否正在利用数据存储库?
  • 参考文献_参考
  • 数据统计 测试方法_统计测试:了解如何为数据选择最佳测试!
  • 每个Power BI开发人员的Power Query提示
  • a/b测试_如何进行A / B测试?
  • 面向数据科学家的实用统计学_数据科学家必知的统计数据
  • 在Python中有效使用JSON的4个技巧
  • 虚拟主机创建虚拟lan_创建虚拟背景应用
  • python 传不定量参数_Python中的定量金融
  • 贝叶斯 朴素贝叶斯_手动执行贝叶斯分析
  • GitHub动作简介
  • 照顾好自己才能照顾好别人_您必须照顾的5个基本数据
  • 认识数据分析_认识您的最佳探索数据分析新朋友
  • arima模型怎么拟合_7个统计测试,用于验证和帮助拟合ARIMA模型
  • 天池幸福感的数据处理_了解幸福感与数据(第1部分)
  • 詹森不等式_注意詹森差距
  • 数据分析师 需求分析师_是什么让分析师出色?
  • 猫眼电影评论_电影的人群意见和评论家的意见一样好吗?
  • ai前沿公司_美术是AI的下一个前沿吗?
  • mardown 标题带数字_标题中带有数字的故事更成功吗?
  • 使用Pandas 1.1.0进行稳健的2个DataFrames验证

足球预测_预测足球热相关推荐

  1. lstm 能耗预测_预测能耗第一部分

    lstm 能耗预测 An Introduction to Time Series Analysis and Forecasting Using Python 使用Python进行时间序列分析和预测的简 ...

  2. java 数据周期预测_预测算法 | Holt Winter季节性指数平滑法 附JAVA代码

    import java.util.ArrayList; import java.util.List; /** * 三次指数平滑预测,最多外推一个周期 * @author Administrator * ...

  3. python 比赛成绩预测_预测球队比赛成绩

    本文尝试采用自顶向下的设计方法进行体育竞技分析.自顶向下即将一个复杂问题分解成几个问题,再细分成一个个具体的小问题,从而来解决复杂问题. 一.采用乒乓球比赛规则(学号尾号为3必做题) 比赛规则:(1) ...

  4. python猪肉价格预测_预测猪肉年底会涨到30元,用python分析:肉涨真正利好哪些股?...

    概要 预测猪肉年底会涨到30元,那么问题来了,肉涨利好哪些股?本文从全国猪肉价格可视化分析,然后用python的pandas数据相关性分析,来选取最有代表性的猪肉价格.最后,提取猪肉概念的30多只股票 ...

  5. arima 预测模型_预测未来:学习使用Arima模型进行预测

    arima 预测模型 XTS对象 (XTS Objects) If you're not using XTS objects to perform your forecasting in R, the ...

  6. 白话 贝叶斯公式_白话贝叶斯理论及在足球比赛结果预测中的应用和C#实现

    贝叶斯分类的基础是概率推理,就是在各种条件的存在不确定,仅知其出现概率的情况下,如何完成推理和决策任务.概率推理是与确定性推理相对应的.而朴素贝叶斯分类器是基于独立假设的,即假设样本每个特征与其他特征 ...

  7. python预测足球比赛_机器学习算法预测足球赛事的模型比较(一)

    本文是作者前一段时间关注足球赛事时做的一点分析,内容涉及基于足球数据进行描述性统计分析.基于机器学习建模与传统的泊松模型建模三大部分,由于文章较长,将分两部分进行展现. 第一部分为前言与述性分析部分1 ...

  8. 白话贝叶斯理论及在足球比赛结果预测中的应用和C#实现

    离去年"马尔可夫链进行彩票预测"已经一年了,同时我也计划了一个彩票数据框架的搭建,分析和预测的框架,会在今年逐步发表,拟定了一个目录,大家有什么样的意见和和问题,可以看看,留言我会 ...

  9. [置顶]白话贝叶斯理论及在足球比赛结果预测中的应用和C#实现

    离去年"马尔可夫链进行彩票预测"已经一年了,同时我也计划了一个彩票数据框架的搭建,分析和预测的框架,会在今年逐步发表,拟定了一个目录,大家有什么样的意见和和问题,可以看看,留言我会 ...

最新文章

  1. 记录一次爬取某昵称网站的爬虫
  2. Cascading(一)之日志解析
  3. Spring的7种事务传播行为类型
  4. 怎么查看python是否安装好了pyinstaller_Python PyInstaller安装和使用教程(详解版)...
  5. 常用Redis命令总结
  6. SAP Spartacus 4.0 ng serve 之后,localhost 4200 会后面自动添上 electronics-spa 吗?
  7. Java 8里一元函数Function的compose和andThen方法区别
  8. 蓝桥杯第八届省赛JAVA真题----分巧克力
  9. 定位叠放次序z-index(HTML、CSS)
  10. 小米2S ROM重分区
  11. vs c语言绘图函数,C语言图形编程(绘图函数部分)
  12. Switch离线升级教程【自用】
  13. arcgis for android(二)显示二维地图
  14. 数据恢复软件从iOS恢复Safari浏览记录
  15. 谷歌浏览器自带的翻译功能无法使用的解决办法
  16. matlab中imapprox,matlab图像处理命令(2)
  17. INT_MAX INT_MIN及其运算
  18. UISlider 滑动条基本属性
  19. c#语言入门 刘老师,c#单元测试实例(学习刘老师视频)
  20. 赛门铁克:政企云建设与安全要双管齐下

热门文章

  1. java中if 运算符_[Java]Java基本语法结构(运算符,流程控制语句,if语句)
  2. 详解vector容器(应用+模拟实现,vector相关练习题)
  3. Shuffle'm Up——简单模拟
  4. Linux网络编程服务器模型选择之并发服务器(下)
  5. 移植驱动完毕后加载时的version magic报错原因以及解决办法
  6. 从外包月薪5K到阿里月薪15K,原理+实战+视频+源码
  7. c语言 大雨 班上多个同学准备,2015年计算机二级考试《C语言》提高练习题(7)
  8. padding影响整个div的实际宽度
  9. [洛谷P5048][Ynoi2019模拟赛]Yuno loves sqrt technology III
  10. CSS仿艺龙首页鼠标移入图片放大