时间序列分析的七种方法

本文介绍了进行时间序列预测的七种方法:1) 傻瓜式方法;2) 简单平均法;3) 移动平均法,包括加权移动平均;4) 单指数平滑法;5) 霍尔特线性趋势法;6) 霍尔特-温特斯季节性方法;7) 自回归积分滑动平均模型(ARIMA)。每种方法通过实例展示了其预测效果。
摘要由CSDN通过智能技术生成

7 methods to perform Time Series forecasting

  • Method 1 – Start with a Naive Approach
  • Method 2 – Simple average
  • Method 3 – Moving average
  • Method 4 – Single Exponential smoothing
  • Method 5 – Holt’s linear trend method
  • Method 6 – Holt’s Winter seasonal method
  • Method 7 – ARIMA
import pandas as pd
import numpy as np
import matplotlib.pylab as plt

%matplotlib inline
# 解决坐标轴刻度负号乱码
plt.rcParams['axes.unicode_minus'] = False
# 解决中文乱码问题
plt.rcParams['font.sans-serif'] = ['Simhei']

from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 18, 6

import warnings
warnings.filterwarnings("ignore")

数据:1981-1990年澳大利亚墨尔本每日最低温度

#Importing data
df = pd.read_csv('Train_SU63ISt.csv')
#Printing head
df.head()
ID Datetime Count
0 0 25-08-2012 00:00 8
1 1 25-08-2012 01:00 2
2 2 25-08-2012 02:00 6
3 3 25-08-2012 03:00 2
4 4 25-08-2012 04:00 2
#Printing tail
df.tail()
ID Datetime Count
18283 18283 25-09-2014 19:00 868
18284 18284 25-09-2014 20:00 732
18285 18285 25-09-2014 21:00 702
18286 18286 25-09-2014 22:00 580
18287 18287 25-09-2014 23:00 534
#Subsetting the dataset
#Index 11856 marks the end of year 2013
df = pd.read_csv('Train_SU63ISt.csv', nrows = 11856)

#Creating train and test set 
#Index 10392 marks the end of October 2013 
train=df[0:10392] 
test=df[10392:]
#Aggregating the dataset at daily level
df.Timestamp = pd.to_datetime(df.Datetime,format='%d-%m-%Y %H:%M') 
df.index = df.Timestamp 
df = df.resample('D').mean()
train.Timestamp = pd.to_datetime(train.Datetime,format='%d-%m-%Y %H:%M') 
train.index = train.Timestamp 
train = train.resample('D').mean() 
test.Timestamp = pd.to_datetime(test.Datetime,format='%d-%m-%Y %H:%M') 
test.index = test.Timestamp 
test = test.resample('D').mean()
#Plotting data
train.Count.plot(figsize=(18,8), title= 'Daily Ridership', fontsize=14)
test.Count.plot(figsize=
  • 4
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值