Skip to content

NKomrade/TATA-Hackathon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TATA Hackathon - Battery Analytics Platform

A comprehensive AI-powered battery analytics platform that provides intelligent insights for battery health monitoring, performance prediction, and lifecycle management. This solution combines advanced machine learning algorithms with real-time analytics to optimize battery usage and promote circular economy principles.

Project Overview

This platform offers:

  • AI-Powered Battery Analytics: Advanced machine learning models for battery health assessment
  • Predictive Maintenance: RUL (Remaining Useful Life) prediction with 99% accuracy
  • Performance Optimization: Real-time monitoring and degradation analysis
  • Circular Economy Integration: Smart recommendations for second-life applications
  • Interactive Dashboard: Comprehensive visualization and reporting tools

Architecture

The project consists of two main components:

Frontend (Next.js + TypeScript)

  • Framework: Next.js 14 with TypeScript
  • UI Components: Custom dashboard with Tailwind CSS
  • Key Features:
    • Battery data upload and visualization
    • Real-time analytics dashboard
    • Predictive modeling interface
    • Report generation and export
    • Interactive charts and graphs

Backend (Python Flask API)

  • Framework: Flask with CORS support
  • ML Libraries: scikit-learn, pandas, numpy
  • Key Features:
    • Battery data processing (.pkl/.csv files)
    • Statistical analysis and metrics calculation
    • Health score assessment
    • Capacity fade analysis
    • Temperature analytics

Project Structure

TATA-Hackathon-main/
├── backend/                         # Python backend, data processing and model utils
│   ├── HFDataPreProcess/            # Battery analytics API + preprocessing utilities
│   │   ├── analyze_calb_data.py
│   │   ├── battery_analytics_api.py
│   │   ├── battery_analytics_client.py
│   │   ├── convert_calb_data.py
│   │   ├── explore_calb_data.py
│   │   ├── README_API.md
│   │   ├── test_api.py
│   │   ├── test_battery_api.py
│   │   └── battery_data_export/     # exported sample data and test inputs
│   └── (other backend utilities)
├── models/                          # Model code, training scripts, checkpoints and datasets
│   ├── assets/                      # Documentation about data structure and training
│   │   ├── Data_structure_description.md
│   │   └── Model_training.md
│   ├── checkpoints/                 # Saved model checkpoints
│   │   ├── CALB_CPTransformer/
│   │   └── CALB_CPTransformer_regularized/
│   ├── data_provider/               # Data loader / factory utilities
│   │   ├── data_factory.py
│   │   ├── data_loader.py
│   │   ├── data_split_recorder.py
│   │   └── life_classes.json
│   ├── dataset/                     # Datasets used for training / evaluation
│   │   ├── CALB/
│   │   ├── "Life Labels"/
│   │   └── seen_unseen_labels/
│   ├── layers/                      # Model layer implementations
│   │   ├── AutoCorrelation.py
│   │   ├── Autoformer_EncDec.py
│   │   ├── Conv_Blocks.py
│   │   ├── Embed.py
│   │   ├── fusion.py
│   │   ├── SelfAttention_Family.py
│   │   └── StandardNorm.py
│   ├── models/                      # Model definitions
│   │   ├── CPBiGRU.py
│   │   ├── CPBiLSTM.py
│   │   ├── CPLSTM.py
│   │   ├── CPMLP.py
│   │   └── CPTransformer.py
│   ├── plot_scripts/                # Plotting utilities for analysis
│   │   └── plt_CALB.py
│   ├── process_scripts/             # Data preprocessing scripts
│   │   └── preprocess_CALB.py
│   ├── read_structure/              # Helpers to read data structure definitions
│   │   └── read_data_structure.py
│   ├── RUL/                         # Remaining Useful Life analysis tools
│   │   ├── predict_rul_simple.py
│   │   └── test_rul_system.py
│   ├── train_eval_scripts/          # Shell scripts to train/evaluate models
│   │   ├── CALB_CPTransformer.sh
│   │   └── evaluate.sh
│   └── utils/                       # Misc utilities (losses, metrics, masking)
│       ├── augmentation.py
│       ├── data_split_helper.py
│       ├── losses.py
│       ├── metrics.py
│       └── timefeatures.py
├── frontend/                        # Next.js TypeScript frontend application
│   ├── app/
│   │   ├── dashboard/
│   │   └── page.tsx
│   ├── components/
│   ├── lib/
│   │   ├── api.ts
│   │   ├── constants.ts
│   │   └── utils.ts
│   ├── public/
│   ├── hooks/
│   └── types/
├── README.md                        # Project README (this file)
└── package.json (frontend)          # Frontend package manifest

Getting Started

Prerequisites

  • Node.js 18+ and npm/yarn
  • Python 3.8+
  • Git

Backend Setup

  1. Navigate to the backend directory:

    cd backend/HFDataPreProcess
  2. Install Python dependencies:

    pip install flask flask-cors pandas numpy matplotlib scikit-learn
  3. Start the Flask API server:

    python battery_analytics_api.py

    The API will start on http://localhost:5000

  4. Verify API is running:

    python test_api.py

Frontend Setup

  1. Navigate to the frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
    # or
    yarn install
  3. Start the development server:

    npm run dev
    # or
    yarn dev
  4. Open your browser: Navigate to http://localhost:3000

Usage

1. Upload Battery Data

  • Support for .pkl and .csv files
  • Drag-and-drop interface or file browser
  • Real-time upload progress tracking

2. Analytics Dashboard

  • Battery Health Metrics: Capacity retention, degradation indicators
  • Performance Analytics: Charge/discharge statistics, temperature analysis
  • Cycle Life Analysis: Fade rates and projections

3. Predictive Models

Transformer-Based Models

  • CPTransformer - Charge-Patch Transformer (Best performer)

Recurrent Neural Networks (RNNs)

  • CPBiLSTM - Charge-Patch Bidirectional LSTM
  • CPLSTM - Charge-Patch LSTM
  • CPBiGRU - Charge-Patch Bidirectional GRU

Multi-Layer Perceptrons (MLPs)

  • CPMLP - Charge-Patch MLP

4. RUL Prediction

  • Remaining Useful Life calculations
  • Configurable EOL (End of Life) thresholds
  • Confidence intervals and uncertainty quantification

5. Reports & Export

  • Automated report generation
  • Multiple export formats (PDF, CSV, JSON)
  • Customizable report templates

API Endpoints

Core Endpoints

  • GET / - Health check and API information
  • POST /api/upload - Upload battery data files
  • GET /api/analytics/{battery_id} - Get analytics results
  • POST /api/predictions - Run ML predictions
  • GET /api/rul/{battery_id} - Calculate remaining useful life

Example API Usage

// Upload battery data
const formData = new FormData();
formData.append('file', batteryFile);

const response = await fetch('http://localhost:5000/api/upload', {
  method: 'POST',
  body: formData
});

const analytics = await response.json();

Model Performance Metrics

  • MAE (Mean Absolute Error): Model accuracy measurement
  • RMSE (Root Mean Square Error): Prediction error quantification
  • R² Score: Coefficient of determination for model fit
  • Training Time: Model efficiency metrics

Features

Core Analytics

  • Battery health assessment with scoring
  • Capacity fade analysis and visualization
  • Temperature impact evaluation
  • Cycle life projection with confidence intervals
  • Coulombic efficiency tracking

Advanced Features

  • Multi-model comparison and validation
  • Real-time data processing
  • Interactive visualization dashboards
  • Automated report generation
  • Export capabilities (JSON, CSV, PDF)

Future Enhancements

  • Real-time IoT data integration
  • Advanced anomaly detection
  • Predictive maintenance scheduling
  • Cloud deployment and scaling
  • Mobile application support

Development

Testing the API

# Test with sample data
python battery_analytics_client.py --file mock_battery_data.pkl

# Test with multiple files
python battery_analytics_client.py --files file1.csv file2.csv file3.csv

# Save results
python battery_analytics_client.py --file data.pkl --output results.json

Environment Variables

Create a .env.local file in the frontend directory:

NEXT_PUBLIC_API_URL=http://localhost:5000
NODE_ENV=development

Performance & Accuracy

  • Prediction Accuracy: 99%+ for RUL estimation
  • Processing Speed: Real-time analysis for datasets up to 100MB
  • Model Training: Supports epoch configurations from 10-500
  • Data Support: Handles both structured (.csv) and serialized (.pkl) formats

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is developed for the TATA Hackathon and follows the competition guidelines.

Troubleshooting

Common Issues

  1. API Connection Failed

    • Ensure Flask server is running on port 5000
    • Check firewall settings
    • Verify API endpoint URL in frontend configuration
  2. File Upload Issues

    • Supported formats: .pkl, .csv
    • Maximum file size: 100MB
    • Ensure proper file permissions
  3. Model Training Errors

    • Check data format and structure
    • Ensure sufficient memory for large datasets
    • Verify model parameters are within valid ranges

Debug Mode

Enable debug information by setting NODE_ENV=development in the frontend.

Support

For technical support or questions:

  • Check the API documentation
  • Review the troubleshooting section above
  • Open an issue in the repository

About

An AI-powered battery analytics platform that provides intelligent insights for battery health monitoring, performance prediction, and lifecycle management. This solution combines advanced machine learning algorithms with real-time analytics to optimize battery usage and promote circular economy principles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors