Sensor-driven AI to preemptively identify defective silicon wafers and streamline semiconductor manufacturing quality control.
Wafer Pulse tackles one of the most expensive problems in semiconductor fabrication β undetected wafer defects. By analyzing readings from 590 in-line sensors, the system classifies wafers as Good (β1) or Bad (+1) before they reach downstream processing, reducing scrap costs and improving yield.
Built on the SECOM (Semiconductor Manufacturing) dataset (1,567 samples, 590 sensor features, ~6.6% defect rate), the pipeline handles real-world challenges: high dimensionality, extreme class imbalance, and pervasive missing data.
- End-to-end ML pipeline β from raw batch sensor files to production-ready predictions.
- Automated data ingestion β consolidates 30+ timestamped CSV batch files into a unified dataset.
- Robust preprocessing β handles 41,951+ missing values across 538 columns via imputation; removes constant/near-zero-variance features (590 β 562).
- Feature scaling β
StandardScalernormalization with a persisted scaler artifact for inference parity. - Mutual Information feature selection β reduces dimensionality from 562 to the top 60 most informative sensors.
- Hyperparameter-tuned models β
GridSearchCVover Random Forest and XGBoost; best model (XGBoost) serialized for serving. - Batch prediction β ingests new batch files, applies the saved scaler and feature selector, and outputs predictions.
- Detailed artifact logging β every pipeline stage produces human-readable reports (data profile, missing-value analysis, feature rankings, model metrics).
- DVC-initialized β data version control scaffolding in place for large-file tracking.
- Code quality tooling β
rufffor linting and formatting with import sorting.
| Category | Technology | Purpose |
|---|---|---|
| Language | Python 3.12 | Core language |
| Data Processing | Pandas, NumPy | Data manipulation & numerical computing |
| Machine Learning | Scikit-learn | Preprocessing, feature selection, Random Forest, metrics |
| Gradient Boosting | XGBoost | Primary classification model |
| Web Framework | Flask | REST API for serving predictions |
| WSGI Server | Gunicorn | Production-grade HTTP server |
| CLI | Click | Command-line interface |
| Config Management | python-dotenv | Environment variable handling |
| Cloud | AWS (S3, EC2, ALB, RDS, Lambda, SNS, CloudWatch, Secrets Manager) | Production deployment and operations |
| Experiment Tracking | MLflow | Model versioning, metadata and metric logging |
| Data Versioning | DVC | Large file tracking & pipeline reproducibility |
| Build System | Setuptools | Python package building |
| Linting & Formatting | Ruff | Fast Python linter + formatter |
| Testing | Pytest, pytest-cov | Unit testing & coverage |
| Package Management | uv, pip | Dependency resolution & installation |
Wafer_Pulse/
β
βββ Makefile # Build automation (install, lint, format, test, clean)
βββ pyproject.toml # Package metadata, build config & ruff settings
βββ requirements.txt # Pinned Python dependencies
βββ LICENSE # MIT License
βββ README.md # β You are here
βββ Dockerfile # π³ API container image (python:3.12-slim + gunicorn)
βββ .env.example # π Environment variable template (WAFER_PROJECT_*)
β
βββ data/
β βββ Training_Batch_Files/ # π₯ Raw sensor CSVs (30+ batch files, 590 sensors each)
β βββ Prediction_Batch_files/ # π₯ Unlabeled batch files for inference
β βββ raw/ # ποΈ Consolidated raw dataset
β βββ preprocessed_data/ # π§ Cleaned & transformed data
β βββ Train_data/ # π― Final training-ready data (top 60 MI features)
β βββ Prediction_Output_File/ # π€ Model predictions
β βββ Artifacts/ # π Pipeline reports & serialized objects (scaler, etc.)
β
βββ models/ # π€ Serialized trained models
β βββ best_model.pkl # XGBoost (lr=0.5, depth=5, n=50)
β
βββ src/
β βββ api/ # π Flask API (/predict, /predict/batch, /health)
β βββ infrastructure/ # βοΈ Cloud integration (AWS/RDS/MLflow/settings)
β βββ lambda_handlers/ # Ξ» S3-triggered batch inference handler
β βββ pipeline_0*.py # ML pipeline stages (prep β preprocess β train β infer)
β
βββ infrastructure/
β βββ terraform/ # ποΈ AWS IaC: VPC, S3, ALB, EC2, RDS, CloudWatch, SNS
β
βββ .github/workflows/ # π CI/CD and scheduled training workflows
β βββ ci.yml
β βββ daily-training.yml
β
βββ config/
β βββ params.yaml # Pipeline hyperparameters and paths
β βββ cloud_provisioning_contract.yaml # AWS resource contract & post-provision outputs
β βββ schema_training.json
β βββ schema_prediction.json
β
βββ tests/ # π§ͺ Test suite
βββ notebooks/ # π Jupyter notebooks (experimentation)
βββ docs/ # π MkDocs documentation site
βββ references/ # π Reference materials & data dictionaries
- Python 3.12+
- pip or uv (recommended)
- Git
- Make (optional, for shortcut commands)
git clone https://github.com/PreritSM/Wafer_Pulse.git
cd Wafer_Pulsepython3 -m venv venv
source venv/bin/activatepip install -U pip
pip install -r requirements.txtpython -c "import src; print('β
wafer project imports correctly')"cp .env.example .envPopulate all required WAFER_PROJECT_* values in .env.
Before provisioning AWS resources, fill:
config/cloud_provisioning_contract.yaml
This file is the single source for:
- Terraform input values (
api_ami_id, CIDRs, alert email, etc.) - Runtime environment values (
WAFER_PROJECT_*) - Post-provision outputs that must be handed back (
api_alb_dns_name,rds_endpoint, subnet IDs, etc.)
After apply, update the post_provision_outputs section with real values.
cd infrastructure/terraform
# Copy the example config and fill in real values
cp minimal.auto.tfvars.example minimal.auto.tfvars
# Edit minimal.auto.tfvars β set api_ami_id, db_password, api_key, alert_email
# Download providers (~674 MB, kept out of git)
terraform init
# Preview
terraform plan -var-file="minimal.auto.tfvars"
# Apply
terraform apply -var-file="minimal.auto.tfvars"
# Tear down
terraform destroy -var-file="minimal.auto.tfvars"Provisioned components include:
- Custom VPC with public/private subnets
- S3 bucket (
s3://wafer-project-pm29/) with versioning + SSE-S3 - RDS PostgreSQL (
db.t3.micro) - Optional internet-facing ALB + EC2 API target
- CloudWatch logs and optional SNS alerts
- Secrets Manager secret for runtime config
Note:
minimal.auto.tfvarsis gitignored. Onlyminimal.auto.tfvars.example(with placeholders) is committed. Never commit a tfvars file with real credentials.
| Command | Description |
|---|---|
make requirements |
Install all Python dependencies |
make clean |
Remove compiled .pyc files and __pycache__/ directories |
make lint |
Check code style with ruff (no auto-fix) |
make format |
Auto-format and fix code with ruff |
make test |
Run the test suite |
make help |
List all available Make targets |
python src/api/main.py
# or with gunicorn:
gunicorn --chdir src "api.main:app" --bind 0.0.0.0:5000| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Liveness β model load status |
POST |
/predict |
Single wafer inference (60 scaled sensor readings) |
POST |
/predict/batch |
Batch inference β list of wafers |
Example:
curl -s -X POST http://localhost:5000/predict \
-H "Content-Type: application/json" \
-d '{"sensor_readings": [0.0, 0.1, ...]}' | python -m json.toolThe
sensor_readingsarray must contain exactly 60 pre-scaled floating-point values (output ofStandardScaler+ Mutual Information feature selection).
Training_Batch_Files/*.csv
β
βΌ
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β Data Ingestion ββββββΆβ raw/combined_secom_data.csv β
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββ
β Preprocessing ββββββΆβ preprocessed_data/preprocessed_*.csv β
β (impute + filter)β ββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β Feature Scaling ββββββΆβ preprocessed_data/scaled_*.csv β
β (StandardScaler) β β Artifacts/feature_scaler.pkl β
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β Feature SelectionββββββΆβ Train_data/selected_features_*.csv β
β (Mutual Info) β β Top 60 of 562 features β
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β Model Training ββββββΆβ models/best_model.pkl β
β (RF vs XGBoost) β β Logged to MLflow β
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β Prediction ββββββΆβ Prediction_Output_File/Predictions β
βββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
| Model | Best Parameters | CV Score | Accuracy | Precision | F1 | ROC-AUC |
|---|---|---|---|---|---|---|
| Random Forest | gini, max_depth=2, log2, n=10 |
0.9338 | 0.9331 | 0.8707 | 0.9008 | 0.6079 |
| XGBoost β | lr=0.5, max_depth=5, n=50 |
0.9354 | 0.9172 | 0.8899 | 0.9015 | 0.6958 |
Note: Model selection uses PR-AUC as the primary metric (best for class imbalance at 6.6% defect rate). ROC-AUC and F1 are logged as supporting metrics.
| Property | Value |
|---|---|
| Samples | 1,567 |
| Sensors (raw features) | 590 |
| Selected features | 60 |
| Good wafers (β1) | 1,463 (93.4%) |
| Defective wafers (+1) | 104 (6.6%) |
| Missing values | 41,951 (4.53% of all cells) |
- Flask API in
src/api/with/predict,/predict/batch,/health. - Cloud integration layer in
src/infrastructure/for settings, retries, S3, RDS persistence, and MLflow tagging. - Batch ingestion Lambda handler in
src/lambda_handlers/batch_ingestion.py. - DVC remote configured to
s3://wafer-project-pm29/dvc-registry/. - Terraform scaffold in
infrastructure/terraform/for VPC, S3, ALB, EC2, RDS, CloudWatch, SNS. - CI workflows in
.github/workflows/including daily training schedule and PR-AUC gate. - MLflow tracking wired into
pipeline_06_model_training.py.
- Apply Terraform with real account values and capture outputs in
config/cloud_provisioning_contract.yaml. - Configure Secrets Manager and start API container on EC2.
- Execute smoke tests against the ALB endpoint and Lambda S3 trigger.
- Enable MLflow model promotion flow (Staging/Production aliases).
This project is licensed under the MIT License β see the LICENSE file for details.
PreritSM β GitHub