├── previous_data.xlsx ├── README.md ├── LICENSE └── Predictor.py /previous_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KN4KNG/LotteryNumberPredictor/HEAD/previous_data.xlsx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Lottery Predictor 3 | 4 | This project is a machine learning model designed to predict the most likely set of lottery numbers for the next drawing based on previous winning numbers. 5 | 6 | ## Getting Started 7 | 8 | To use this model, you will need to have Python installed on your computer, as well as the following libraries: 9 | 10 | - pandas 11 | - scikit-learn 12 | 13 | To install the libraries, run the following command: 14 | 15 | Copy code 16 | 17 | `pip install pandas scikit-learn` 18 | 19 | ## Usage 20 | 21 | 1. Download the previous winning lottery numbers from your state's lottery website and save them in an Excel file. 22 | 2. Run the `Predictor.py` file, which will train a Random Forest Regression model on the previous winning numbers and generate a set of predicted numbers. 23 | 3. The program will output the most likely set of numbers for the next drawing. 24 | 25 | ## License 26 | 27 | This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). You are free to use, modify, and distribute this project as long as you give attribution to the original author. 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Alex Bowman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Predictor.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.ensemble import RandomForestRegressor 3 | from random import randint 4 | 5 | i = 0 6 | while i < 10: 7 | # Load the data from Excel file 8 | data = pd.read_excel("previous_data.xlsx") 9 | 10 | # Split the data into features (X) and target (y) 11 | X = data[['1st_number', '2nd_number', '3rd_number', '4th_number', '5th_number', '6th_number']] 12 | y = data.iloc[:, 1:] 13 | 14 | # Train a Random Forest Regression model 15 | model = RandomForestRegressor(n_estimators=1000, random_state=None) 16 | model.fit(X, y) 17 | 18 | # Generate a new set of random features for prediction 19 | new_data = pd.DataFrame({ 20 | "1st_number": [randint(1, 70) for _ in range(100)], 21 | "2nd_number": [randint(1, 70) for _ in range(100)], 22 | "3rd_number": [randint(1, 70) for _ in range(100)], 23 | "4th_number": [randint(1, 70) for _ in range(100)], 24 | "5th_number": [randint(1, 70) for _ in range(100)], 25 | "6th_number": [randint(1, 25) for _ in range(100)], 26 | }) 27 | 28 | # Use the trained model to predict the next 6 numbers for each set of features 29 | predictions = model.predict(new_data) 30 | 31 | # Get the most likely set of numbers based on the predictions 32 | most_likely_set = predictions[0] 33 | for p in predictions: 34 | if p[0] > most_likely_set[0]: 35 | most_likely_set = p 36 | 37 | # Convert most_likely_set to whole numbers 38 | rounded_most_likely_set = [round(x) for x in most_likely_set] 39 | 40 | # Print the most likely set of numbers 41 | print(str(f"{i+1:02d}") + ". The most likely set of numbers is:", rounded_most_likely_set) 42 | i += 1 43 | --------------------------------------------------------------------------------