# Binary Classify a Large Data Set using Deep Learning

I tried training this model: All even integers map to T and all odd ones map to F. I used 100 million training examples with Support Vector Machine as the method yet I got garbage for the test cases. Same with all other methods. What am I doing wrong?

• This is a difficult thing to learn stats.stackexchange.com/q/161189 . You'd need better features if you wanted to learn parity, and that's entirely unnecessary since Mod[x,2] already does the job perfectly. – flinty Oct 4 at 13:33
• Thanks but obviously this example is a proxy for more complicated data that shows rapid oscillations. – Quasar Supernova Oct 4 at 15:36
• Your question did not mention a proxy model. However, the reasoning still applies. You'd still need more features in the data, even if that meant just getting the binary expansions as feature vectors IntegerDigits[#,2,numdigits]->class[#]&/@numbers – flinty Oct 4 at 15:42

This answer is from @GalAster . I simply translate it.

End-to-end double-layer LSTM can

Simple network two-layer LSTM

Automatic loss function, automatic parameter tuning algorithm, cross-validation 10% per round

The test set is a string of numbers below 10^12, the accuracy is 100%, perfect

makeRule[i_] := IntegerString[i] -> If[OddQ@i, "Odd", "Even"];
trainingData = Flatten@Table[makeRule[i], {i, 0, 10000}];
net = NetChain[
{
UnitVectorLayer[],
LongShortTermMemoryLayer[40],
LongShortTermMemoryLayer[20],
SequenceLastLayer[],
LinearLayer[2],
SoftmaxLayer[]
},
"Input" -> NetEncoder[{"Characters", {DigitCharacter}}],
"Output" -> NetDecoder[{"Class", {"Odd", "Even"}}]
]
trained = NetTrain[
net, trainingData, All,
MaxTrainingRounds -> 25,
ValidationSet -> Scaled[0.1],
TargetDevice -> "GPU"
]
eval = trained["TrainedNet"];
eval["123456789101112131415"]
eval["20200202"]
eval["114514"]
eval["19260817"]

testingData = Table[makeRule[i], {i, RandomInteger[10^12, 10^4]}];
NetMeasurements[trained["TrainedNet"], testingData, "Accuracy"]