bevisrefiner/human-resource-prediction
Live Streaming Manpower Prediction System

Introduction
The Live Streaming Manpower Prediction System is a decision support tool based on Machine Learning (Random Forest). It is designed to address the challenges in project management where manpower scheduling often relies on subjective experience, involves tedious calculations, and is prone to errors.
Leveraging real-world project execution data from 2024-2025, this project transforms unstructured business requirements into model features through feature engineering. It predicts the optimal manpower allocation for various project types, enabling managers to perform more precise resource planning.
Business Value
- Efficiency: Automates the tedious manpower calculation process, reducing administrative time.
- Data-Driven: Transforms "rules of thumb" into "data models," providing an objective basis for dispatching.
- Usability: Offers both Tkinter (Desktop) and Gradio (Web) interfaces, making it accessible to non-technical administrative staff.
Tech Stack
- Language: Python
- Data Processing: Pandas, NumPy
- Machine Learning: Scikit-learn (RandomForestRegressor)
- GUI: Tkinter, Gradio
Interface Preview
This project provides interfaces tailored to different usage scenarios:
🚀 Online Demo (Hugging Face Spaces)
The project's user prediction interface has been deployed to Hugging Face Spaces and is ready for use. **Try it now!**
1. Gradio Web App (Modern Web Interface)
Ideal for browser-based operations with a sleek and intuitive design. 
2. Tkinter GUI (Native Desktop Interface)
Suitable for lightweight local environments without the need for a browser. 
Data Pipeline & Feature Engineering
The raw data is derived from actual business scenarios and undergoes rigorous cleaning and transformation before training.
1. Preprocessing
- Data Cleaning: Handling missing values and outliers to ensure data quality.
- Time Feature Transformation:
- Converts absolute time (e.g.,
10:00-14:00) into relative duration (e.g.,4.0 Hours). - Decomposes date factors (Month/Day/Weekday) and applies One-Hot Encoding for "Is Holiday".
- Categorical Feature Encoding:
- Applies One-Hot Encoding to "Project Type" and "Technical Requirements" to digitize business logic.
2. Model Training Pipeline
The training process is automated via code/Train.py and involves the following steps:
- Data Loading: Reads raw data from the configured path.
- Preprocessing:
- Removes irrelevant columns (ID, Project Name, Date).
- Applies One-Hot Encoding to categorical features (e.g., 'Job Type').
- Splits data into Features (X) and Labels (y).
- Data Splitting: Divides data into 80% training set and 20% testing set to ensure objective evaluation.
- Hyperparameter Tuning:
- Uses GridSearchCV with 5-fold Cross-Validation.
- Optimizes parameters like
n_estimators(Number of trees) andmin_samples_split(Leaf node splitting condition) to prevent overfitting. - Model Evaluation:
- Calculates MSE, RMSE, and R-squared scores on the test set.
- The best model is selected based on the lowest validation error.
- Serialization: The final model is wrapped in a dictionary containing both the model object and feature metadata, then saved as a
.pklfile for deployment.
- Algorithm: Random Forest Regressor (Ensemble Learning)
- Key Parameters Tuned:
n_estimators: [50, 100, 150, 200]max_depth: [None, 10, 20, 30]min_samples_split: [2, 5, 10]
Performance
The model's performance on the test set is as follows. Considering that manpower allocation is typically an integer (0-8 people), an RMSE of 0.507 indicates that the prediction error is controlled within ±0.5 people, making it highly reliable.
Usage
Choose the execution method that best fits your workflow.
0. Prerequisites
Before the first run, ensure your Python environment is set up and install the required packages:
pip install -r ./deploy/requirements.txt1-1. Tkinter GUI (Desktop App)
Best for users who prefer traditional windowed applications.
- Locate the
tkinter.batfile in the project directory. - Double-click to launch the application window.
1-2. Gradio Web App (Web Interface)
Best for users who prefer a modern browser interface.
- Locate the
gradio.batfile in the project directory. - Double-click to execute the startup script.
- Open your browser and navigate to
http://127.0.0.1:7860to access the interface.
Future Roadmap
This project is currently an experimental standalone version. Future optimization plans include:
- Automated ETL Pipeline: Establish an automated data cleaning process to improve efficiency.
- Database Integration: Introduce SQL databases to replace CSV storage, ensuring data consistency and security.
- Scheduling Optimization: Integrate staff skill tags to upgrade from predicting "headcount" to recommending specific "personnel lists."
- CI/CT: Implement a mechanism for model retraining to automatically update model parameters as new data accumulates.
