灰色预测模型_python

[

_灰色预测模型_是一种基于指数平滑方法的预测模型,可以用于预测非线性和不确定性系统的发展趋势。在 _Python_中,可以使用NumPy和Pandas等库实现 _灰色预测模型_的数学建模。 以下是一个简单的 _灰色预测模型_的 _Python_代码示例: import numpy as np import pandas as pd def GM11(x0): # 累加生成序列 x1 = np.cumsum(x0) # 紧邻均值生成序列 z1 = (x1[:-1] + x1[1:]) / 2.0 # 紧邻均值生成序列矩阵 Z = pd.DataFrame(z1, columns=['Z1']) # 矩阵B B = np.append(-Z.values, np.ones((len(Z), 1)), axis=1) # 矩阵Y Y = x0[1:].reshape((len(x0) - 1, 1)) # 矩阵a [[a], [b]] = np.dot(np.dot(np.linalg.inv(np.dot(B.T, B)), B.T), Y) # 模型精度的后验差检验 x0_hat = np.zeros(len(x0)) x0_hat[0] = x0[0] for i in range(1, len(x0)): x0_hat[i] = (x0[0] - b / a) * np.exp(-a * (i)) + b / a # 求原序列x0的一次累加序列 x1_hat = np.cumsum(x0_hat) # 返回原始值、预测值和一次累加序列 return x0, x0_hat, x1_hat 使用该函数进行 _灰色预测模型_的预测,可以输入原始数据序列x0,返回原始值、预测值和一次累加序列。例如: x0 = np.array([13, 15, 16, 18, 21, 22, 23, 25, 26, 28]) x0, x0_hat, x1_hat = GM11(x0) print('原始值:', x0) print('预测值:', x0_hat) print('一次累加序列:', x1_hat)](https://wenku.csdn.net/answer/bdaa02c6e07b4daf90e07892b0df1aee)

Original: https://blog.csdn.net/qq_34229228/article/details/123581540
Author: hellobigorange
Title: 灰色预测模型_python

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/726947/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球