CoolFace
Apppublic

bevisrefiner/human-resource-prediction

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
App README

Live Streaming Manpower Prediction System

Python Scikit-learn Gradio Status ![Hugging Face Spaces](https://huggingface.co/spaces/bevisrefiner/human-resource-prediction)

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. Gradio Demo

2. Tkinter GUI (Native Desktop Interface)

Suitable for lightweight local environments without the need for a browser. Tkinter Demo


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:

  1. 1.Data Loading: Reads raw data from the configured path.
  2. 2.Preprocessing:
  3. 3.Removes irrelevant columns (ID, Project Name, Date).
  4. 4.Applies One-Hot Encoding to categorical features (e.g., 'Job Type').
  5. 5.Splits data into Features (X) and Labels (y).
  6. 6.Data Splitting: Divides data into 80% training set and 20% testing set to ensure objective evaluation.
  7. 7.Hyperparameter Tuning:
  8. 8.Uses GridSearchCV with 5-fold Cross-Validation.
  9. 9.Optimizes parameters like n_estimators (Number of trees) and min_samples_split (Leaf node splitting condition) to prevent overfitting.
  10. 10.Model Evaluation:
  11. 11.Calculates MSE, RMSE, and R-squared scores on the test set.
  12. 12.The best model is selected based on the lowest validation error.
  13. 13.Serialization: The final model is wrapped in a dictionary containing both the model object and feature metadata, then saved as a .pkl file 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.

MetricValueDescription
MSE0.257Mean Squared Error
RMSE0.507Root Mean Squared Error (Primary Metric)

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:

bash
pip install -r ./deploy/requirements.txt

1-1. Tkinter GUI (Desktop App)

Best for users who prefer traditional windowed applications.

  1. 1.Locate the tkinter.bat file in the project directory.
  2. 2.Double-click to launch the application window.

1-2. Gradio Web App (Web Interface)

Best for users who prefer a modern browser interface.

  1. 1.Locate the gradio.bat file in the project directory.
  2. 2.Double-click to execute the startup script.
  3. 3.Open your browser and navigate to http://127.0.0.1:7860 to access the interface.

Future Roadmap

This project is currently an experimental standalone version. Future optimization plans include:

  1. 1.Automated ETL Pipeline: Establish an automated data cleaning process to improve efficiency.
  2. 2.Database Integration: Introduce SQL databases to replace CSV storage, ensuring data consistency and security.
  3. 3.Scheduling Optimization: Integrate staff skill tags to upgrade from predicting "headcount" to recommending specific "personnel lists."
  4. 4.CI/CT: Implement a mechanism for model retraining to automatically update model parameters as new data accumulates.