Spaces:
Running
Running
| # Tests Directory | |
| Automated test and validation scripts for the AI Battery Lifecycle Predictor. | |
| ## Test Scripts | |
| ### 1. `test_v2_models.py` β Comprehensive V2 Validation | |
| Validates all 14 v2 classical models against test set with detailed reporting. | |
| **Usage:** | |
| ```bash | |
| python tests/test_v2_models.py | |
| ``` | |
| **Output:** | |
| - `artifacts/v2/results/v2_model_validation.csv` β Full metrics table | |
| - `artifacts/v2/results/v2_validation_summary.json` β Summary statistics | |
| - `artifacts/v2/figures/validation_accuracy_bars.png` β Accuracy ranking chart | |
| - `artifacts/v2/figures/r2_vs_accuracy.png` β RΒ² vs accuracy scatter plot | |
| - `artifacts/v2/figures/best_model_analysis.png` β Best model performance | |
| - `artifacts/v2/figures/per_battery_accuracy.png` β Per-battery accuracy heatmap | |
| - `artifacts/v2/results/v2_validation_report.html` β HTML report | |
| - `artifacts/v2/results/v2_validation_report.md` β Markdown report | |
| **Target Metrics:** | |
| - Within-Β±5% SOH Accuracy β₯ 95% (primary success metric) | |
| - Within-Β±2% SOH Accuracy (secondary) | |
| - RΒ² β₯ 0.95 (correlation) | |
| - MAE β€ 3% (mean absolute error) | |
| ### 2. `test_predictions.py` β Quick Endpoint Validation | |
| Quick validation of prediction endpoint with sample features on model registry. | |
| **Usage:** | |
| ```bash | |
| python tests/test_predictions.py | |
| ``` | |
| **Output:** Console output showing predictions for 4 test scenarios: | |
| - Early life cycle (SOH β 99%) | |
| - Healthy cycle (SOH β 97%) | |
| - Degraded cycle (SOH β 80%) | |
| - End-of-life cycle (SOH β 40%) | |
| ## Running Tests | |
| ### Run all tests | |
| ```bash | |
| python tests/test_v2_models.py | |
| python tests/test_predictions.py | |
| ``` | |
| ### Run individual test | |
| ```bash | |
| python tests/test_v2_models.py # V2 model validation | |
| python tests/test_predictions.py # Endpoint test | |
| ``` | |
| ## Test Data | |
| Tests use: | |
| - **Features:** `artifacts/v2/results/battery_features.csv` (2,678 samples) | |
| - **Target:** SOH (State of Health) percentage | |
| - **Split:** Intra-battery chronological (first 80% cycles β train, last 20% β test) | |
| - **Batteries:** All 30 usable batteries in both train and test | |
| ## Model Versions Tested | |
| | Model | Category | V2 Status | | |
| |-------|----------|-----------| | |
| | ExtraTrees | Tree | β v2.0.0 | | |
| | GradientBoosting | Tree | β v2.0.0 | | |
| | RandomForest | Tree | v1.0.0 | | |
| | XGBoost | Tree | v1.0.0 | | |
| | LightGBM | Tree | v1.0.0 | | |
| | SVR | Linear | v1.0.0 | | |
| | Ridge | Linear | v1.0.0 | | |
| | Lasso | Linear | v1.0.0 | | |
| | ElasticNet | Linear | v1.0.0 | | |
| | KNN (k=5, 10, 20) | Linear | v1.0.0 | | |
| ## Success Criteria | |
| β Model passes if: **Within-Β±5% Accuracy β₯ 95%** | |
| Current pass rate: See latest report in `artifacts/v2/results/v2_validation_report.html` | |