arima 预测模型

XTS对象 (XTS Objects)

If you’re not using XTS objects to perform your forecasting in R, then you are likely missing out! The major benefits that we’ll explore throughout are that these objects are a lot easier to work with when it comes to modeling, forecasting, & visualization.

如果您没有使用XTS对象在R中执行预测,那么您很可能会错过! 我们将始终探索的主要好处是,在建模,预测和可视化方面,这些对象更易于使用。

让我们进入细节 (Let’s Get to The Details)

XTS objects are composed of two components. The first is a date index and the second of which is a traditional data matrix.

XTS对象由两个组件组成。 第一个是日期索引,第二个是传统数据矩阵。

Whether you want to predict churn, sales, demand, or whatever else, let’s get to it!

无论您是要预测客户流失,销售,需求还是其他,我们都可以开始吧!

The first thing you’ll need to do is create your date index. We do so using the seq function. Very simply this function takes what is your start date, the number of records you have or length, and then the time interval or by parameter. For us, the dataset starts with the following.

您需要做的第一件事是创建日期索引。 我们使用seq函数。 很简单,此功能需要的只是你的开始日期,你有记录的数目或长度,然后将时间间隔或by参数。 对于我们来说,数据集从以下开始。

days <- seq(as.Date("2014-01-01"), length = 668, by = "day")

Now that we have our index, we can use it to create our XTS object. For this, we will use the xts function.

现在我们有了索引,可以使用它来创建XTS对象。 为此,我们将使用xts函数。

Don’t forget to install.packages('xts') and then load the library! library(xts)

不要忘了先安装install.packages('xts') ,然后加载库! library(xts)

Once we’ve done this we’ll make our xts call and pass along our data matrix, and then for the date index we will pass the index to the order.by option.

完成此操作后,我们将进行xts调用并传递数据矩阵,然后对于日期索引,我们会将索引传递给order.by选项。

sales_xts <- xts(sales, order.by = days)

让我们与Arima建立预测 (Let’s Create a Forecast with Arima)

Arima stands for auto regressive integrated moving average. A very popular technique when it comes to time series forecasting. We could spend hours talking about ARIMA alone, but for this post, we’re going to give a high-level explanation and then jump directly into the application.

有马代表自动回归综合移动平均线。 关于时间序列预测的一种非常流行的技术。 我们可能只花几个小时来谈论ARIMA,但是在这篇文章中,我们将给出一个高级的解释,然后直接进入该应用程序。

AR:自回归 (AR: Auto Regressive)

This is where we predict outcomes using lags or values from previous months. It may be that the outcomes of a given month have some dependency on previous values.

在这里,我们使用前几个月的滞后或值来预测结果。 给定月份的结果可能与以前的值有一定的依赖性。

一:集成 (I: Integrated)

When it comes to time series forecasting, an implicit assumption is that our model depends on time in some capacity. This seems pretty obvious as we probably wouldn’t make our model time based otherwise ;). With that assumption out of the way, we need to understand where on the spectrum of dependence time falls in relation to our model. Yes, our model depends on time, but how much? Core to this is the idea of Stationarity; which means that the effect of time diminishes as time goes on.

在进行时间序列预测时,一个隐含的假设是我们的模型在某种程度上取决于时间。 这似乎很明显,因为我们可能不会将模型时间设为其他时间;)。 有了这个假设,我们需要了解与我们的模型有关的依赖时间范围。 是的,我们的模型取决于时间,但是多少? 核心思想是平稳性 ; 这意味着随着时间的流逝,时间的影响减弱。

Going deeper, the historical average of a dataset tends to be the best predictor of future outcomes… but there are certainly times when that’s not true.. can you think of any situations when the historical mean would not be the best predictor?

更深入地讲,数据集的历史平均值往往是未来结果的最佳预测因子……但是,在某些情况下,这是不正确的……您能想到历史均值不是最佳预测因子的任何情况吗?

  • How about predicting sales for December? Seasonal Trends预测12月的销售情况如何? 季节性趋势
  • How about sales for a hyper-growth saas company? Consistent upward trends一家高速增长的saas公司的销售情况如何? 一致的上升趋势

This is where the process of Differencing is introduced! Differencing is used to eliminate the effects of trends & seasonality.

这就是引入差分过程的地方! 差异用于消除趋势和季节性的影响。

MA:移动平均线 (MA: Moving Average)

the moving average model exists to deal with the error of your model.

存在移动平均模型以处理模型误差。

让我们开始建模吧! (Let’s Get Modeling!)

火车/验证拆分 (Train/Validation Split)

First things first, let’s break out our data into a training dataset and then what we’ll call our validation dataset.

首先,让我们将数据分为训练数据集,然后将其称为验证数据集。

What makes this different than other validation testing, like cross-validation testing is that here we break it out by time, breaking train up to a given point in time and breaking out validation for everything thereafter.

与其他验证测试(例如交叉验证测试)不同的是,这里我们按时间细分,将训练分解到给定的时间点,然后对所有内容进行验证。

train <- sales_xts[index(sales_xts) <= "2015-07-01"] validation <- sales_xts[index(sales_xts) > "2015-07-01"]

是时候建立模型了 (Time to Build a Model)

The auto.arima function incorporates the ideas we just spoke about to approximate the best arima model. I will detail the more hands-on approach in another post, but below I’ll explore the generation of an auto.arima model and how to use it to forecast.

auto.arima函数结合了我们刚才谈到的想法,可以近似最佳arima模型。 我将在另一篇文章中详细介绍更多的动手方法,但是下面我将探讨auto.arima模型的生成以及如何使用它进行预测。

model <- auto.arima(train)

Now let’s generate a forecast. The same way we did before, we’ll create a date index and then create an xts object with the data matrix.

现在让我们生成一个预测。 与之前相同,我们将创建一个日期索引,然后使用数据矩阵创建一个xts对象。

From here you will plot the validation data and then throw the forecast on top of the plot.

在这里,您将绘制验证数据,然后将预测放在该图的顶部。

forecast <- forecast(model, h = 121) forecast_dates <- seq(as.Date("2015-09-01"), length = 121, by = "day")forecast_xts <- xts(forecast$mean, order.by = forecast_dates)plot(validation, main = 'Forecast Comparison')lines(forecast_xts, col = "blue")

结论 (Conclusion)

I hope this was a helpful introduction to ARIMA forecasting. Be sure to let me know what’s helpful and any additional detail you’d like to learn about.

我希望这对ARIMA预测很有帮助。 请务必让我知道有什么帮助以及您想了解的任何其他详细信息。

If you found this helpful be sure to check out some of my other posts on datasciencelessons.com. Happy Data Science-ing!

如果您认为这有帮助,请务必在datasciencelessons.com上查看我的其他一些帖子。 快乐数据科学!

翻译自: https://towardsdatascience.com/predicting-the-future-learn-to-forecast-with-arima-models-879853c46a4d

arima 预测模型


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

相关文章:

  • bigquery_在BigQuery中链接多个SQL查询
  • mysql 迁移到tidb_通过从MySQL迁移到TiDB来水平扩展Hive Metastore数据库
  • 递归函数基例和链条_链条和叉子
  • 足球预测_预测足球热
  • 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部分)
  • 詹森不等式_注意詹森差距
  • 数据分析师 需求分析师_是什么让分析师出色?

arima 预测模型_预测未来:学习使用Arima模型进行预测相关推荐

  1. R语言构建logistic回归模型并评估模型:模型预测结果抽样、可视化模型分类预测的概率分布情况、使用WVPlots包绘制ROC曲线并计算AUC值

    R语言构建logistic回归模型并评估模型:模型预测结果抽样.可视化模型分类预测的概率分布情况.使用WVPlots包绘制ROC曲线并计算AUC值 目录

  2. R语言中ARMA,ARIMA(Box-Jenkins),SARIMA和ARIMAX模型用于预测时间序列数据

    在本文中,我将介绍ARMA,ARIMA(Box-Jenkins),SARIMA和ARIMAX模型如何用于预测给定的时间序列数据. 使用后移运算符计算滞后差异 我们可以使用backshift运算符来执行 ...

  3. 探索未知.预测未来------利用机器学习(CART)预测合格率

    人类一直试图让机器具有智能,也就是人工智能(Artificial Intelligence).从上世纪50年代,人工智能的发展经历了"推理期",通过赋予机器逻辑推理能力使机器获得智 ...

  4. 学生成绩预测模型_逻辑回归实战练习——根据学生成绩预测是否被录取

    前言: 在学习了梯度下降和逻辑回归的基本算法后,选取此案例来进行实践练习,本次练习主要通过python中的三大块pandas.numpy和matplotlib来实现,基本不涉及到sklearn库的调用 ...

  5. python 主语_前深度学习时代--FFM模型的原理与Python实现

    基于上一篇分析中协同过滤.逻辑回归及FM的比较,可以得出这样一个结论: 主流模型迭代的关键在于增强模型表达能力,而增强方式的主要脉络为: 引入其它可用特征信息(CF->LR). 将现有特征进行组 ...

  6. H.266/VVC帧间预测技术学习:CU级双向加权预测(Bi-prediction with CU-level weight)

    CU级双向加权预测(Bi-prediction with CU-level weight ,BCW) 在HEVC中,通过对从两个不同参考图片获得的两个预测信号求平均和/或使用两个不同运动矢量来生成双向 ...

  7. python用于股票预测有用吗_卧槽,我学会了用Python预测股票价格

    作为一种技术手段,预测在金融.证券领域的应用非常广泛,尤其是对股票价格的预测.我们介绍一下获得股票数据的方法,并基于此对数据进行预处理,接着使用数据分析方法,建立基础特征,进一步构建预测模型,且基于新 ...

  8. zillow房价预测比赛_Zillow预测: 未来一年美国房价将大幅上涨!

    2017年,美国房产市场欣欣向荣,吸引着越来越多的海外人士前往置业投资.据Zillow房价预测显示,未来一年,美国的房产市场仍然将会非常火爆,从全美范围来看,中等房屋的价格将从现在起一年内将上涨6,2 ...

  9. 深度估计学习(单个图像的预测)

    1.安装环境 conda install pytorch=0.4.1 torchvision=0.2.1 -c pytorch pip install tensorboardX==1.4 conda ...

最新文章

  1. 智能车竞赛动力锂电池
  2. Windows 8下看漫画的程序发布
  3. UWP AppBarButton Icon 图标样式集合
  4. linux ssh 报错failed - POSSIBLE BREAK-IN ATTEMPT
  5. Python与数据库(1)mysql
  6. 4090万美元成交!马斯克又卖出三处住宅以兑现“无房产”诺言
  7. 在WinMain中嵌Console窗口
  8. R语言的常用函数速查
  9. 自动超频_超频的几种方式
  10. cas4实现sso(一)cas简介
  11. ajhua门禁_大华门禁主机密码 ajhua门禁
  12. 16天7000dict
  13. IC卡管理系统(Java基础)
  14. ​基于光通信的6G水下信道建模综述
  15. 还在为不知道怎么学习网络安全而烦恼吗?这篇文带你从入门级开始学习网络安全—认识网络安全
  16. 如何修改Oracle VM virtualbox虚拟机的屏幕大小
  17. 美素将进入中国空间站,以太空科技打造“国货之光”
  18. DB Browser for sqlite
  19. Your PHP version does not satisfy that requirement
  20. 20个CC0素材网站【自用】

热门文章

  1. 作为唯一索引_Mysql什么情况下不走索引?
  2. 链表面试题3:将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成 的。
  3. 【Java学习笔记五】Java异常处理
  4. Linux信号之signal函数
  5. 【Linux系统编程学习】匿名管道pipe与有名管道fifo
  6. 北理工爬虫课程学习记录
  7. 对Faster R-CNN的理解(1)
  8. Java概述、环境变量、注释、关键字、标识符、常量
  9. static、volatile、synchronize
  10. 快速排序和快速选择(quickSort and quickSelect)算法