Here's some code that facilitates exploration of the ideas. The notion is that perhaps Machine Learning can be used to compute the next prime mod 3 from some sequence of preceding primes mod 3. The optional argument digitToCheck extends the idea to see whether one could predict the nth digit of the a prime from the nth digit of its predecessor primes. (all mod 3)
cm[predecessors_Integer, trainingRange_: {4, 10000},
testingRange_: {10001, 20000}, digitToCheck_: - 1] :=
Module[{trainingData =
Map[Most@# -> Last@# &,
Partition[
Map[IntegerDigits[#, 3][[digitToCheck]] &,
Table[Prime[i], {i, trainingRange[[1]], trainingRange[[2]]}]],
predecessors + 1, 1]], c, m},
c = Classify[trainingData];
m = ClassifierMeasurements[c,
Map[Most@# -> Last@# &,
Partition[
Map[IntegerDigits[#, 3][[digitToCheck]] &,
Table[Prime[i], {i, testingRange[[1]], testingRange[[2]]}]],
predecessors + 1, 1]]];
Sow[Association["Classifier" -> c, "ClassifierMeasurements" -> m,
"Predecessors" -> predecessors, "TrainingRange" -> trainingRange,
"TestingRange" -> testingRange]];
m["Accuracy"]
]
And here are some preliminary experiments you can run:
cm[1, {10000, 19999}, {50000,
59999}, -1](* just use immediate predecessor *)
cm[2, {10000, 19999}, {50000, 59999}, -1](* two predecessors *)
cm[3, {10000, 19999}, {50000, 59999}, -1](* three predecessors *)
cm[1, {10000, 19999}, {50000,
59999}, -1](* training and testing data far apart *)
cm[1, {20000, 29999}, {50000,
59999}, -1](* different training data far apart *)
cm[1, {10000, 19999}, {50000,
59999}, -2] (* just use immediate predecessor but check whether the \
second to last digit predicts *)
cm[2, {10000, 19999}, {50000,
59999}, -2](* two predecessors but check whether the second to last \
digit predicts*)