DEV Community

Cover image for Florida Lottery Powerball Winning Number Generator and Predictor
Mithun Khatri
Mithun Khatri

Posted on

Florida Lottery Powerball Winning Number Generator and Predictor

An effort to make sense out of random winning numbers/draws in last 10 years


Odds of winning the Powerball lottery jackpot is 1:222M. Despite of known understanding that the drawn numbers are completely random, this project is an effort to identify pattern in jackpot winning draws based on the history of Powerball draws.

This project uses neural network algorithm to classify the draw to be winning or losing. Random number generator tool generates n random draws which are then passed through the Multilayer Perceptron Classifier to find out the winning numbers. Classifier accuracy has been measured up-to 97.4% (which also means there is 2.6% of tolerance). It should be noted that the numbers generated by this project may not be the next jackpot, but it certainly increases the chances of winning the jackpot. Generated numbers may not be the next jackpot, but it will eventually be in future draws.

This project is mere an experiment. Owner of this project is not responsible of any monetary or emotional loss. Also, owner is not willing to grab any piece of monetary gain done by the generated numbers. User should understand that the generated numbers are mere suggestions, and not the jackpot number as yet.



Project Details

Dataset source

Powerball History Draws

Machine Learning

  • Library : scikit-learn
  • Scripting : Python
  • File operations : Pandas
  • Classifiers :
    • MLPClassifier
    • SGDClassifier

Random Number Generator

  • Application name : winners-analysis
  • Type : Spring Boot with RestController to trigger number generation and writing to csv

Technical Details

The dataset

  • Powerball winning number data from Florida Lottery website
  • Mega Millions winning number data from Florida Lottery website
  • Pdf data transformed into csv
  • Training data set prepared by mixing winning and random losing numbers

Number Generator

The Spring project : winners-analysis

It generates n draws containing numbers which are randomly generated.

The ranges of numbers are :

1 : 1–69
2 : 1–69
3 : 1–69
4 : 1–69
5 : 1–69
PB : 1–26
Enter fullscreen mode Exit fullscreen mode

These generated numbers are written to csv file which can be used as test data for the machine learning model.

Draws generator APIs

  • GET /draw/generate/{n} : Generate n draws and write to csv file which can be supplied to machine learning model for prediction
  • GET /draw/repeatedRandom/{n} : Generate m draws (∀ m <= n) and write to csv file that can be supplied to machine learning model for prediction. The generated draws are the repeated combination of the draws when random numbers generated n times. Theory says these numbers may have higher chances to be the jackpot number. Also, it returns ~1300 out of 1 million random generated draws, which are then passed through the model results in ~20 lucky numbers.

Machine learning model

Multi-layer Perceptron model with 100 hidden layers has been used to reach accuracy ~ 97%.

Below steps are used to perform machine learning:

  1. Collect training data (csv) generated by winners-analysis Spring project.
  2. Read csv using pandas library and split train and test data with 20% test data.
Initialize MLPClassifier from sklearn.neural-network
from sklearn.neural_network import MLPClassifier
clf = MLPClassifier(alpha=1, max_iter=5000)
Enter fullscreen mode Exit fullscreen mode
  1. Fit training data into the classifier
  2. Predict output for the test data and calculate the accuracy
from sklearn.metrics import accuracy_score
score = accuracy_score(y_test, y_pred)
Enter fullscreen mode Exit fullscreen mode

Activity

Pick the latest draw winning and pass through the model for prediction. There is 97% chances the result is going to be winning.


TODO

  • Automate end to end flow
  • Deploy and make it available for public
  • Real-time retraining the model after each Powerball draw to improve the accuracy over the period

✌️

Top comments (3)

Collapse
 
signo profile image
L

Maybe I'm missing something, but if numbers are always completely random what are you expecting?
If the output is random past performances are not indicative of future results

Collapse
 
iceorfiresite profile image
Ice or Fire

"Random" is never truly random... if you flip a coin 1000 times you're not going to get 500 heads and 500 tails. Over time it will trend toward fifty/fifty but it won't reach it.

Collapse
 
signo profile image
L

Ofc you're not going to get 500 heads and 500 tails, that's why it's random. You'll never predict the output of a coin flip using past results.
Regarding the random used for the lottery I suggest you to read this answer:
quora.com/Are-lottery-winning-numb...