Simple Binary Classification Example in Python I'm not sure the correct place to ask, but I'm trying to develop a simple function/algorithm that outputs a predicted number from a sequence of numbers (I have a background in Python, but little to no experience working with data prediction). More specifically, when there is only binary choice. I looked around online, but I'm really lost and couldn't quite find something discussing it:

Suppose there's a bunch of 1s and 0s in sequence, like:

0100010010111011010010001011010

Suppose there is some complex math pattern that is determining the sequence, even though it is unbeknownst to us observers. However we know for certain that this data is not random, and contains no anomalies.

What sort of function can be used to predict if the next digit is a 1 or 0?

For example:

01010101 -> the next digit predicted should be 0.

001100110011 -> the next digit predicted should be 0.

Is there some simple Python function (using numpy, pandas, etc.) that can predict the next 1 or 0, no matter the pattern?
The problem you are describing is a type of sequence prediction.

I think this is too complicated for any numpy or pandas library to solve. Maybe sklearn has something close, but I think a neural network would give you the most accurate predictions.

Before deciding, some of the points to consider are:


Is there a limit on max length for the string pattern you are
looking for?
Do you only want one prediction, based on one pattern that is
considered most likely, or do you want to consider multiple
patterns?
Others


Examples:
001001001 -> next digit should be 001
01001010010 -> there are 2 subpatterns and another larger pattern. next digiti could be 50% chance of 0 (01 pattern) and 50% chance of 1 (001 pattern)

I think the best approach is to let an LSTM find any patterns and predict the next digit based on the model it built. The model will contain all the information mentioned above without you needing to define them.

Depending on how simple or complicated you want to make this, you could start with a simple LSTM model and go from there. 

https://machinelearningmastery.com/sequence-prediction/

or

https://machinelearningmastery.com/models-sequence-prediction-recurrent-neural-networks/