description
You read that correctly. That’s the start to a real integer sequence, the powers of primes. Want something easier? How about the next number in 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55? If you answered 89, you may enjoy this challenge. Your computer may find it considerably less enjoyable.
The On-Line Encyclopedia of Integer Sequences is a 50+ year effort by mathematicians the world over to catalog sequences of integers. If it has a pattern, it’s probably in the OEIS, and probably described with amazing detail. This competition challenges you create a machine learning algorithm capable of guessing the next number in an integer sequence. While this sounds like pattern recognition in its most basic form, a quick look at the data will convince you this is anything but basic!
Interger Sequence:
题目大意:给你一个整数序列,预测下一个值是多少?
1、通过前面序列,使用自回归模型得到参数,得到一个表达式,
d[n] = d[n-1] * a[0] + d[n-2] * a[1] + … d[n-1 - p] * a[p];
但是自回归模型最大的问题,就是p是跟数据有关系的,一般通过观察得到p,例如求自协方差,偏协方差系数,观测等等,
我们这里可以假设p = 2,3,4,5…
怎么判断p的值?
例如:p=2
根据前几个数据得到参数,进行测试后几个值,如果误差在10^-2之内,我们就接受这个模型,并在所有序列中,去掉它,
在剩下的序列中,测试 p = 3,重复上面的操作,知道所有的序列都被满足,或者达到某种条件结束(防止此方法不能判断所有的序列),
import pandas as pd
import numpy as np