足球预测_预测足球热

足球预测

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年。 数据似乎显示出一些我们可以研究的强烈季节性趋势。

Image for post

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周,几个月或几年的线性组合。

Image for post

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

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

Image for post

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检验进行检验。

Image for post

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的参数。

Image for post
Image for post

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.

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

Image for post

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:

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

Image for post

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:

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

Image for post

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.

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

Image for post

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

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

Image for post

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.

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

Image for post

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.mzph.cn/news/388805.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C#的特性Attribute

一、什么是特性 特性是用于在运行时传递程序中各种元素&#xff08;比如类、方法、结构、枚举、组件等&#xff09;的行为信息的声明性标签&#xff0c;这个标签可以有多个。您可以通过使用特性向程序添加声明性信息。一个声明性标签是通过放置在它所应用的元素前面的方括号&am…

python3中朴素贝叶斯_贝叶斯统计:Python中从零开始的都会都市

python3中朴素贝叶斯你在这里 (You are here) If you’re reading this, odds are: (1) you’re interested in bayesian statistics but (2) you have no idea how Markov Chain Monte Carlo (MCMC) sampling methods work, and (3) you realize that all but the simplest, t…

【转载】移动端布局概念总结

布局准备工作及布局思想及概念: 一个显示器&#xff08;pc端显示器 及 手机屏显示器&#xff09;&#xff0c;既有物理像素&#xff0c;又有独立像素&#xff08;独立像素也叫作css像素&#xff0c;用于前端人员使用&#xff09;&#xff1b; -->重要 首先确定设计稿的尺寸…

深入浅出:HTTP/2

上篇文章深入浅出&#xff1a;5G和HTTP里给自己挖了一根深坑&#xff0c;说是要写一篇关于HTTP/2的文章&#xff0c;今天来还账了。 本文分为以下几个部分&#xff1a; HTTP/2的背景HTTP/2的特点HTTP/2的协议分析HTTP/2的支持 HTTP/2简介 HTTP/2主要是为了解决现HTTP 1.1性能不…

画了个Android

画了个Android 今晚瞎折腾&#xff0c;闲着没事画了个机器人——android&#xff0c;浪费了一个晚上的时间。画这丫还真不容易&#xff0c;为那些坐标&#xff0c;差点砸了键盘&#xff0c;好在最后画出个有模有样的&#xff0c;心稍安。 下面来看看画这么个机器人需要些什么东…

数据治理 主数据 元数据_我们对数据治理的误解

数据治理 主数据 元数据Data governance is top of mind for many of my customers, particularly in light of GDPR, CCPA, COVID-19, and any number of other acronyms that speak to the increasing importance of data management when it comes to protecting user data.…

提高机器学习质量的想法_如何提高机器学习的数据质量?

提高机器学习质量的想法The ultimate goal of every data scientist or Machine Learning evangelist is to create a better model with higher predictive accuracy. However, in the pursuit of fine-tuning hyperparameters or improving modeling algorithms, data might …

mysql 集群实践_MySQL Cluster集群探索与实践

MySQL集群是一种在无共享架构(SNA&#xff0c;Share Nothing Architecture)系统里应用内存数据库集群的技术。这种无共享的架构可以使得系统使用低廉的硬件获取高的可扩展性。MySQL集群是一种分布式设计&#xff0c;目标是要达到没有任何单点故障点。因此&#xff0c;任何组成部…

matlab散点图折线图_什么是散点图以及何时使用

matlab散点图折线图When you were learning algebra back in high school, you might not have realized that one day you would need to create a scatter plot to demonstrate real-world results.当您在高中学习代数时&#xff0c;您可能没有意识到有一天需要创建一个散点图…

python字符串和List:索引值以 0 为开始值,-1 为从末尾的开始位置;值和位置的区别哦...

String&#xff08;字符串&#xff09;Python中的字符串用单引号 或双引号 " 括起来&#xff0c;同时使用反斜杠 \ 转义特殊字符。 字符串的截取的语法格式如下&#xff1a; 变量[头下标:尾下标]索引值以 0 为开始值&#xff0c;-1 为从末尾的开始位置。[一个是值&#x…

逻辑回归 python_深入研究Python的逻辑回归

逻辑回归 pythonClassification techniques are an essential part of machine learning and data science applications. Approximately 70% of problems in machine learning are classification problems. There are lots of classification problems that are available, b…

spring定时任务(@Scheduled注解)

&#xff08;一&#xff09;在xml里加入task的命名空间 xmlns:task"http://www.springframework.org/schema/task" http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd&#xff08;二&#xff09;启用注…

JavaScript是如何工作的:与WebAssembly比较及其使用场景

*摘要&#xff1a;** WebAssembly未来可期。 原文&#xff1a;JavaScript是如何工作的&#xff1a;与WebAssembly比较及其使用场景作者&#xff1a;前端小智Fundebug经授权转载&#xff0c;版权归原作者所有。 这是专门探索 JavaScript及其所构建的组件的系列文章的第6篇。 如果…

Matplotlib中的“ plt”和“ ax”到底是什么?

Indeed, as the most popular and fundamental data visualisation library, Matplotlib is kind of confusing in some perspectives. It is usually to see that someone asking about的确&#xff0c;作为最受欢迎的基础数据可视化库&#xff0c;Matplotlib在某些方面令人困…

2018年阿里云NoSQL数据库大事盘点

2019独角兽企业重金招聘Python工程师标准>>> NoSQL一词最早出现在1998年。2009年Last.fm的Johan Oskarsson发起了一次关于分布式开源数据库的讨论&#xff0c;来自Rackspace的Eric Evans再次提出了NoSQL概念&#xff0c;这时的NoSQL主要是指非关系型、分布式、不提供…

cayenne:用于随机模拟的Python包

TL;DR; We just released v1.0 of cayenne, our Python package for stochastic simulations! Read on to find out if you should model your system as a stochastic process, and why you should try out cayenne.TL; DR; 我们刚刚发布了 cayenne v1.0 &#xff0c;这是我们…

java 如何将word 转换为ftl_使用 freemarker导出word文档

近日需要将人员的基本信息导出&#xff0c;存储为word文档&#xff0c;查阅了很多资料&#xff0c;最后选择了使用freemarker&#xff0c;网上一共有四种方式&#xff0c;效果都一样&#xff0c;选择它呢是因为使用简单&#xff0c;再次记录一下,一个简单的demo&#xff0c;仅供…

DotNetBar office2007效果

1.DataGridView 格式化显示cell里的数据日期等。 进入编辑列&#xff0c;选择要设置的列&#xff0c;DefaultCellStyle里->行为->formart设置 2.tabstrip和mdi窗口的结合使用给MDI窗口加上TabPage。拖动个tabstrip到MDI窗口上tabstrip里选择到主窗口名就加上TABPAGE了。d…

spotify 数据分析_没有数据? 没问题! 如何从Wikipedia和Spotify收集重金属数据

spotify 数据分析For many data science students, collecting data is seen as a solved problem. It’s just there in Kaggle or UCI. However, that’s not how data is available daily for working Data Scientists. Also, many of the datasets used for learning have …

IS环境下配置PHP5+MySql+PHPMyAdmin

IIS环境下配置PHP5MySqlPHPMyAdmin Posted on 2009-08-07 15:18 谢启祥 阅读(1385)评论(18) 编辑 收藏 虽然主要是做.net开发的&#xff0c;但是&#xff0c;时不时的还要搞一下php&#xff0c;但是&#xff0c;php在windows下的配置&#xff0c;总是走很多弯路&#xff0c;正好…