An end-to-end Machine Learning and web application for classifying industrial chemical production batches into operational performance clusters using K-Means clustering.
- Overview
- Project Architecture
- Features
- Machine Learning Model & Clusters
- Project Structure
- Setup & Installation
- API Endpoints
This project classifies chemical batch manufacturing data in real-time. By analyzing 10 key production variables (such as temperature, pressure, reaction time, yield, purity, and energy consumption), an unsupervised K-Means Clustering model assigns each batch to one of three operational quality categories.
The application is structured into a modern two-tier architecture:
- Frontend (React + Vite + CSS3): A clean, responsive industrial UI that collects process input variables and presents real-time cluster classifications.
- Backend (Python Flask + Scikit-Learn): REST API service that accepts JSON payload, scales inputs with a pre-trained
StandardScaler, and predicts the cluster using a trainedKMeansmodel (joblib).
graph TD
UI[React Frontend UI] -->|POST /get_clusters| API[Flask Backend API]
API --> SCALER[StandardScaler - scaler.pkl]
SCALER --> MODEL[K-Means Model - kmeans_model.pkl]
MODEL -->|Cluster ID| API
API -->|JSON Response: Cluster, Name, Description| UI
- Real-time Batch Classification: Predicts cluster membership instantly upon form submission.
- Multi-variable Parameter Input: Evaluates 10 distinct physical & chemical metrics:
- Temperature (°C) & Pressure (atm)
- Reaction Time (min) & Cooling Time (min)
- Catalyst Loading (%) & pH Level
- Yield (%) & Purity (%)
- Energy (kWh) & Mixing Speed (RPM)
- Pre-trained ML Models: Uses Scikit-Learn
KMeansandStandardScalerloaded viajoblib. - Clean Industrial UI: Responsive React interface designed with an emphasis on clarity and accessibility.
The model segments production batches into three distinct operational profiles:
| Cluster ID | Cluster Name | Profile & Description |
|---|---|---|
| 0 | Optimised Production | High purity and yield accompanied by low operating costs. |
| 1 | Standard Production | Moderate purity and yield with baseline production costs. |
| 2 | High Risk Production | Low purity and yield paired with high energy/operating costs. |
manifacturing_batch_clustering_system/
│
├── backend/ # Flask REST API
│ ├── app.py # Main Flask application & routes
│ ├── requirments.txt # Python dependencies
│ └── model/ # Pre-trained ML models
│ ├── kmeans_model.pkl # Trained KMeans model
│ └── scaler.pkl # Fitted StandardScaler object
│
├── batch-clustering/ # React Frontend (Vite)
│ ├── src/
│ │ ├── App.jsx # Parent App component
│ │ ├── FormData.jsx # Batch parameter input form & result display
│ │ ├── index.css # Styling rules & design system
│ │ └── main.jsx # Entry point
│ ├── package.json # Node dependencies
│ └── vite.config.js # Vite configuration
│
├── data/ # Raw & processed manufacturing datasets
└── clustering_system.ipynb # Jupyter Notebook for EDA, preprocessing, and model training
- Python 3.8+
- Node.js 16+ &
npm
-
Navigate to the backend directory:
cd backend -
Create and activate a Python virtual environment:
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install required dependencies:
pip install flask flask-cors joblib pandas scikit-learn
-
Start the Flask API server:
python app.py
The server runs locally at
http://127.0.0.1:5001/
-
Open a new terminal and navigate to the frontend directory:
cd batch-clustering -
Install Node packages:
npm install
-
Start the Vite development server:
npm run dev
-
Open your browser and navigate to
http://localhost:5173/(or the URL outputted by Vite).
- Description: Health check endpoint.
- Response:
"Manufacturing API is running Successfully"
- Description: Accepts batch metrics and returns predicted cluster info.
- Request Body Example:
{ "temperature": 129, "pressure": 2.5, "reaction_time": 45, "catalyst_loading": 1.2, "pH": 7.0, "yield_pct": 94.5, "purity_pct": 98.2, "energy": 320, "cooling_time": 15, "mixing_speed": 1500 } - Response Example:
{ "status": "success", "cluster": 0, "name": "Optimised Production", "description": "High Purity and Yield with low Operating Cost" }
This repository is maintained for industrial manufacturing process analytics.