python
import pmdarima as pm
from pmdarima.model_selection import train_test_split
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime #数据索引改为时间
import numpy as np
from numpy import diff
import statsmodels.api as sm #acf,pacf图
from statsmodels.tsa.stattools import adfuller #adf检验
from pandas.plotting import autocorrelation_plot
from statsmodels.tsa.arima_model import ARIMA
##读取数据
data = pd.read_csv(r'C:\Users\13771\Desktop\outpatient expenses-days.CSV',index_col=u'TONGJIRQ')
data = pd.DataFrame(data)
temp = np.array(data["FEIYONG"])
##ADF检验
t = adfuller(temp)
print('The ADF Statistic of bls yield: %f' % t[0])
print('The p value of bls: %f' % t[1])
#自动定阶
pmax = int(len(data) / 10) #一般阶数不超过 length /10
qmax = int(len(data) / 10)
print(pmax)
model = pm.auto_arima(temp, start_p=1, start_q=1,
&n

本文介绍了如何使用Python的pmdarima库进行ARIMA模型的自动化选择和预测,通过ADF检验确保数据平稳性,然后针对医疗费用数据进行分析,展示了自动定阶和模型预测的过程。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



