# Python 项目 lightGBM算法数据预测 **Repository Path**: kiku-lu/python-video-testing ## Basic Information - **Project Name**: Python 项目 lightGBM算法数据预测 - **Description**: 该仓库用于B站视频展示代码的下载 B站视频合集:https://space.bilibili.com/16336309/lists/6412314?type=season - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-11-19 - **Last Updated**: 2025-11-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Python Machine Learning & Prediction System Collection ## Project Overview This is a comprehensive Python machine learning project collection that encompasses multiple prediction systems and algorithm implementations. The project covers traditional machine learning, deep learning, and reinforcement learning, suitable for scenarios such as sales forecasting, data analysis, and intelligent decision-making. ## Project Structure ``` python-video-testing/ ├── 📊 actual_case_sales_forecast/ # Mobile Accessories Sales Forecast System (Complete Solution) │ ├── unified_prediction_system.py # Unified Prediction System Main Entry │ ├── sales_prediction_system.py # Sales Prediction System Core │ ├── sales_prediction_models.py # Prediction Models Module │ ├── sales_prediction_pipeline.py # Prediction Pipeline │ ├── data_analysis.py # Data Analysis Tools │ ├── debug_system.py # Debug System │ ├── view_results.py # Results Viewer │ └── 系统架构说明.md # System Architecture Documentation │ ├── 🤖 reinforcement_learning_algorithms/ # Reinforcement Learning Algorithm Implementation │ └── rl_algorithms.py # DQN, Double DQN, Dueling DQN, etc. │ ├── 📈 traditional_machine_learning/ # Traditional Machine Learning Prediction System │ ├── main.py # Main Program Entry (837 lines complete implementation) │ ├── stacking_model.py # Stacking Model Integration (493 lines) │ ├── stacking_predict.py # Stacking Prediction Interface (105 lines) │ ├── test.py # LightGBM Test Class │ ├── test1.py # Data Processing Tools │ ├── test2.py # Strategy Module │ └── mysql.py # MySQL Database Operations │ ├── 📁 other_tools_and_test_files/ │ ├── main_complex.py # Complex Version Main Program │ ├── lightgbm_order.xlsx # LightGBM Order Data │ ├── original_data.xlsx # Original Dataset │ ├── mysql.docx # MySQL Documentation │ ├── model_test.txt # Model Test Records │ ├── Dockerfile # Docker Container Configuration │ ├── LICENSE # License File │ └── .gitignore # Git Ignore File │ └── 📄 documentation/ ├── README.md # Chinese Documentation (This File) └── README.en.md # English Documentation ``` ## 🎯 Core Features ### 1. Mobile Accessories Sales Forecast System (actual_case_sales_forecast) **Key Features:** - 🔄 **Dual Data Source Support**: Excel files + MySQL database - 🤖 **Multi-model Integration**: LinearRegression, Ridge, RandomForest, GradientBoosting, TimeSeries - ⚖️ **Multiple Integration Methods**: Simple average, weighted average, median, trimmed mean - 📊 **Complete Prediction Pipeline**: Data preprocessing → Model training → Prediction → Result integration → Post-processing → Evaluation - 🛠️ **Rich Auxiliary Tools**: Data analysis, debug system, result viewer **Usage Examples:** ```bash # Quick prediction mode python actual_case_sales_forecast\unified_prediction_system.py quick # Advanced prediction mode (multi-model + ensemble) python actual_case_sales_forecast\unified_prediction_system.py advanced --models LinearRegression,RandomForest --ensemble weighted_average # Data analysis mode python actual_case_sales_forecast\unified_prediction_system.py analyze ``` ### 2. Stacking Model Integration System **Key Features:** - 🧠 **Intelligent Model Selection**: Dynamically adjust hyperparameters based on data characteristics - 📈 **Multi-algorithm Support**: LightGBM, XGBoost, RandomForest, Ridge, Lasso, ElasticNet, SVR, etc. - 🔧 **Automatic Hyperparameter Tuning**: GridSearchCV automatic optimization - 📊 **Complete Evaluation System**: RMSE, MAE, R2, MAPE, custom accuracy **Usage Example:** ```bash # Run Stacking prediction python stacking_predict.py ``` ### 3. Reinforcement Learning Algorithm Library **Key Features:** - 🧠 **Multiple DQN Variants**: Standard DQN, Double DQN, Dueling DQN - 🎯 **Actor-Critic Methods**: A2C, A3C algorithms - 📦 **Experience Replay Mechanism**: Standard replay + prioritized replay - 🔧 **Modular Design**: Easy to extend and customize **Core Algorithms:** - DQN (Deep Q-Network) - Double DQN (Reduces Overestimation) - Dueling DQN (Separates Value and Advantage) - Actor-Critic (Policy Gradient Methods) ## 🚀 Quick Start ### Environment Requirements - Python 3.7+ - Windows/Linux/macOS ### Install Dependencies ```bash # Basic dependencies pip install pandas numpy scikit-learn matplotlib openpyxl xlrd # Machine learning specialized pip install lightgbm xgboost # Database support pip install pymysql sqlalchemy # Reinforcement learning (optional) pip install torch ``` ### Data Preparation The system uses the following file structure by default: - `1.xlsx` - Training data - `2.xlsx` - Prediction data - `3.xlsx` - Output results ### Run Prediction #### Method 1: Use Sales Forecast System (Recommended) ```bash cd actual_case_sales_forecast python unified_prediction_system.py quick ``` #### Method 2: Use Stacking Model ```bash python stacking_predict.py ``` #### Method 3: Use Traditional Machine Learning Pipeline ```bash python main.py ``` ## 📊 System Features ### 🎯 Prediction Accuracy - **Multi-model Integration**: Improve prediction stability through model diversity - **Intelligent Hyperparameter Tuning**: Automatically optimize model parameters based on data characteristics - **Post-processing Optimization**: Outlier handling, business rule application ### 🔧 Usability - **One-click Operation**: Complete prediction process with simple commands - **Detailed Logging**: Complete operation logs and error prompts - **Flexible Configuration**: Support for command-line parameters and configuration files ### 📈 Extensibility - **Modular Architecture**: Easy to add new models and algorithms - **Plugin Design**: Support for custom preprocessing and post-processing - **Multi-data Source**: Support for Excel, MySQL, CSV and other formats ## 🎨 Evaluation Metrics The system provides comprehensive model evaluation metrics: - **RMSE** (Root Mean Square Error) - **MAE** (Mean Absolute Error) - **R²** (Coefficient of Determination) - **MAPE** (Mean Absolute Percentage Error) - **Custom Accuracy** (Special metric optimized for small values) ## 🔍 Troubleshooting ### Common Issues 1. **Insufficient Memory**: Reduce batch size or use simpler models 2. **Data Format Error**: Ensure Excel file format is correct and column names match 3. **MySQL Connection Failed**: Check database configuration and network connection ### Debug Tools - Use `debug_system.py` for system diagnostics - View detailed log output to locate issues - Use `data_analysis.py` to analyze data quality ## 🚀 Future Extensions ### Planned Features - 🌐 **Web Interface**: Flask/Django-based web application - 📱 **API Interface**: RESTful API service - 🧠 **Deep Learning**: Add neural network models - 📊 **Visualization**: Chart display of prediction results - ⚡ **Performance Optimization**: Parallel computing and caching mechanisms ### Contribution Guidelines Issues and Pull Requests are welcome to improve system functionality. ## 📄 License This project adopts the MIT License - see [LICENSE](LICENSE) file for details ## 🏷️ Version History - **v2.0** (Current): Unified prediction system, supports Excel+MySQL dual data sources - **v1.5**: Reinforcement learning algorithm library - **v1.0**: Basic Stacking model integration system