Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Powerball Prediction System

A comprehensive machine learning-based system for Powerball lottery number prediction, now refactored into a modular architecture for better maintainability and extensibility.

Issues Fixed

  • CSV Header Misalignment: Fixed missing "Powerball" column in powerball.csv headers
  • Data Mapping Errors: Corrected incorrect column mapping that was treating 'Day' as 'Year' and misaligning number columns
  • Code Organization: Refactored large monolithic file into specialized modules

Modular Architecture

The system is now organized into specialized modules:

Core Modules

  1. data_handler.py - Data loading, preparation, and feature engineering

    • PowerballDataHandler class handles CSV loading and data preprocessing
    • Properly maps columns: Month, Day, Year, Num 1-5, Powerball, PowerPlay
    • Engineers comprehensive features for prediction algorithms
  2. cache_manager.py - Caching system for model training and features

    • CacheManager class handles model and feature caching
    • Validates cache based on data and model hashes
    • Improves performance by avoiding redundant computations
  3. models.py - Neural networks and ensemble model definitions

    • PowerballLSTM - LSTM model for sequence prediction
    • AdvancedPowerballLSTM - Advanced LSTM with attention mechanism
    • EnsembleModelBuilder - Builds ensemble of ML models (RF, XGBoost, etc.)
  4. predictors.py - Core prediction algorithms

    • PredictionEngine class with multiple prediction methods
    • ML-based, pattern-based, and hybrid prediction strategies
    • Ensures prediction diversity and uniqueness
  5. evaluators.py - Testing and evaluation methods

    • PredictionEvaluator class for comprehensive testing
    • Historical stress testing against past draws
    • Future simulation testing with synthetic draws
    • Performance scoring and statistical analysis
  6. visualizers.py - Data visualization and analysis plots

    • PowerballVisualizer class for creating comprehensive charts
    • Frequency heatmaps, temporal analysis, correlation matrices
    • Prediction vs historical comparison plots
  7. main_predictor.py - Main orchestrator class

    • AdvancedPowerballPredictor coordinates all components
    • Provides high-level interface for prediction workflows
    • Includes convenience functions and example usage

Quick Start

Simple Usage

from main_predictor import quick_prediction

# Generate 10 predictions quickly
predictions = quick_prediction('powerball.csv', num_predictions=10)

Advanced Usage

from main_predictor import AdvancedPowerballPredictor

# Initialize the system
predictor = AdvancedPowerballPredictor('powerball.csv')

# Generate predictions using different methods
ml_predictions = predictor.generate_predictions(5, method='ml')
pattern_predictions = predictor.generate_predictions(5, method='pattern') 
hybrid_predictions = predictor.generate_predictions(5, method='hybrid')

# Test predictions
test_results = predictor.test_predictions(ml_predictions)

# Create visualizations
predictor.create_visualizations()

# Run comprehensive analysis
results = predictor.run_comprehensive_analysis()

Individual Component Usage

# Use components individually
from data_handler import PowerballDataHandler
from predictors import PredictionEngine
from evaluators import PredictionEvaluator

data_handler = PowerballDataHandler('powerball.csv')
prediction_engine = PredictionEngine(data_handler)
evaluator = PredictionEvaluator(data_handler)

# Generate features and predictions
features = data_handler.engineer_features()
predictions = prediction_engine.generate_pattern_based_predictions(features)
results = evaluator.stress_test(predictions)

Data Format

The system expects a CSV file with the following headers:

Month,Day,Year,Num 1,Num 2,Num 3,Num 4,Num 5,Powerball,PowerPlay (if applicable)

Example data row:

10,3,2015,33,6,46,44,26,4,2

Where:

  • Month, Day, Year: Draw date
  • Num 1-5: White ball numbers (1-69)
  • Powerball: Red powerball number (1-26)
  • PowerPlay: Multiplier (optional)

Files

Original (deprecated)

  • powerballPredictions.py - Original monolithic implementation

New Modular System

  • data_handler.py - Data loading and preprocessing
  • cache_manager.py - Caching system
  • models.py - ML models and neural networks
  • predictors.py - Prediction algorithms
  • evaluators.py - Testing and evaluation
  • visualizers.py - Data visualization
  • main_predictor.py - Main orchestrator
  • example_usage.py - Usage examples

Data

  • powerball.csv - Historical Powerball draws (headers now corrected)

Generated

  • model_cache/ - Cached models and features
  • stress_test_results/ - Test results and performance data
  • visualizations/ - Generated charts and plots

Features

  • Multiple Prediction Methods: ML-based, pattern-based, and hybrid approaches
  • Comprehensive Testing: Historical and future simulation stress testing
  • Advanced Analytics: Feature engineering, statistical analysis, correlation studies
  • Visualization: Interactive plots for data exploration and prediction analysis
  • Caching: Intelligent caching for improved performance
  • Modular Design: Easy to extend and maintain

Performance

The system has been optimized for:

  • Fast prediction generation (< 5 seconds for 10 predictions)
  • Efficient feature engineering with caching
  • Comprehensive testing against historical data
  • Memory-efficient model training and inference

Requirements

  • Python 3.7+
  • pandas, numpy, scikit-learn
  • xgboost, lightgbm
  • pytorch (for neural networks)
  • plotly (for visualizations)
  • statsmodels, prophet (for time series analysis)

Note

This system is for educational and entertainment purposes. Lottery numbers are random and no prediction system can guarantee winning numbers.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages