【问题标题】:How to use trial and error algorithm to predict the next number in a sequence?如何使用试错算法来预测序列中的下一个数字?
【发布时间】:2019-02-01 18:48:29
【问题描述】:

我有一个时间序列数据。我想使用试错算法来预测variation_sequence 中的下一个数字。我的意思是试错算法正在使用在线学习,而我没有关于序列的更多信息。有可能使用 n 阶马尔可夫预测器。

但是不知道哪种算法适合order-n Markov predictor?如果有替代的可能性?

import matplotlib.pyplot as plt

time_in_minute = [1, 11, 21, 26, 35, 39]
variation_sequence = [449.48, 553.57, 696.783, 870.133, 1000.4, 1309.1]
plt.plot(time_in_minute, variation_sequence, color='orange')
plt.xlabel('Variation')
plt.ylabel('Time')
plt.title('Variation of data')
plt.show()

【问题讨论】:

  • 分享你的variation变量值
  • @Alderven 你能检查一下编辑过的问题吗?
  • 请不要分享 png 文件,而是分享变量值以在您的脚本中使用它
  • @Alderven 非常感谢您的帮助。我是试错算法的新手。因此,如果我对您的请求不感到困惑,我想预测的变量值是变化variation_sequence = [449.48, 553.57, 696.783, 870.133, 1000.4, 1309.1]

标签: python machine-learning


【解决方案1】:

你可以使用简单的线性回归

from sklearn.linear_model import LinearRegression

X = [1960, 1970, 1980, 1990, 2000, 2010] 
y = [449.48, 553.57, 696.783, 870.133, 1000.4, 1309.1]  
X = np.array(X)
#Reshape since it expects 2D array
X = X.reshape(-1, 1)
model = LinearRegression()
model.fit(X, y)

X_predict = [2020]
X_predict= np.array(X_predict)
X_predict= X_predict.reshape(-1, 1)
y_predict = model.predict(X_predict)
print y_predict

输出

[1394.43833333]

【讨论】:

  • 非常感谢您的帮助。但当我说试错算法时,我的意思是在线试错预测,例如强化学习算法;
  • @Rishi Bansal 我们不能将监督学习应用于时间序列数据。这不是一种有效的方法。
猜你喜欢
  • 1970-01-01
  • 2018-11-20
  • 2023-03-05
  • 1970-01-01
  • 2018-04-03
  • 2019-09-21
  • 1970-01-01
  • 2020-06-01
  • 1970-01-01
相关资源
最近更新 更多