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:
python tests/test_v2_models.py
Output:
artifacts/v2/results/v2_model_validation.csvβ Full metrics tableartifacts/v2/results/v2_validation_summary.jsonβ Summary statisticsartifacts/v2/figures/validation_accuracy_bars.pngβ Accuracy ranking chartartifacts/v2/figures/r2_vs_accuracy.pngβ RΒ² vs accuracy scatter plotartifacts/v2/figures/best_model_analysis.pngβ Best model performanceartifacts/v2/figures/per_battery_accuracy.pngβ Per-battery accuracy heatmapartifacts/v2/results/v2_validation_report.htmlβ HTML reportartifacts/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:
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
python tests/test_v2_models.py
python tests/test_predictions.py
Run individual test
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