NeerajCodz's picture
feat: full project β€” ML simulation, dashboard UI, models on HF Hub
f381be8

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 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:

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