<jupyter_start><jupyter_text>加载数据<jupyter_code>leaf = ('i38', 'e10', 'c1', 'p13', 'l4') #  diff=1
# leaf = ('i38', 'e10', 'c1', 'p10', 'l3')
leaf = ('&').join(leaf)
ts = pd.read_csv('../result/leaves/leaves_KPISet_smothing/%s.csv' % leaf)
colName = 'smoothed'
ts1 = ts[colName][:2016]
ts2 = ts['true'][2016:]<jupyter_output><empty_output><jupyter_text>数据探索<jupyter_code>explore = Explore()
# 平稳性检测
d = explore.stationarity_test(ts1)

# 滚动统计
explore.rolling_statistics(ts1, 288)

# 平稳性检测
d = explore.stationarity_test(ts1, True)

#对序列做白噪声检验
isWN = explore.whitenoise_test(ts1, d, True)

# 画出自相关系数与偏自相关系数
explore.plot_acfandpacf(ts1)
explore.rolling_statistics(ts[colName], 288)<jupyter_output><empty_output><jupyter_text>数据训练和预测<jupyter_code>arima = ARIMAPredict(leaf)
# 训练模型
arima.train(ts1, d, 2, 3, select=False)
# 预测
ts_pred = ts2
if d == 1:
    ts_pred = ts2.diff(d).dropna()
predict = arima.predict(ts_pred)

if d == 1:
    predict =  predict + ts2[:-d]
# 可视化预测结果
arima.plot_results(ts2[d:], predict)
# 保存模型
arima.save('../')<jupyter_output><empty_output><jupyter_text>加载模型<jupyter_code># arima1 = ARIMAPredict('i06&e10&c5&p11&l4')
# arima1.load('../model')
# predict = arima1.predict(ts2)
# arima.plot_results(ts2, predict)<jupyter_output><empty_output><jupyter_text>结果评估<jupyter_code>eva = Evalutaion()
eva.evaluate(ts2[d:], predict, 'MAE', True)
eva.visualize(ts2[d:], predict)<jupyter_output>MAE 180.123309733<jupyter_text>如果训练数据与测试数据一致则结果为原生的ARMA样本内预测<jupyter_code>arima2 = ARIMAPredict(leaf)
# 训练模型
arima2.train(ts2, d, 5, 1, select=False)
# 预测
ts_pred2 = ts2
if d == 1:
    ts_pred2 = ts2.diff(d).dropna()
predict2 = arima2.predict(ts_pred2)

if d == 1:
    predict2 =  predict2 + ts2[:-d]
# 可视化预测结果
arima2.plot_results(ts2[d:], predict2)
eva = Evalutaion()
eva.evaluate(ts2[d:], predict2, 'MAE', True)
eva.visualize(ts2[d:], predict2)<jupyter_output>MAE 179.431722888
{'fraction_non_alphanumeric': 0.17659574468085107, 'fraction_numerical': 0.05851063829787234, 'mean_word_length': 6.9033613445378155, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '311990', 'license': 'Apache-2.0', 'n_tokens_mistral': 989, 'n_tokens_neox': 976, 'n_words': 122, 'path': 'hotspot/code/ARIMA.ipynb', 'repo_name': 'FudanYuan/faultLocalization', 'size': '1880'}