GithubHelp home page GithubHelp logo

shauryashivam / long-live-the-battery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dsr-18/long-live-the-battery

0.0 0.0 0.0 1.17 MB

Predicting total battery cycle life time with machine learning

Jupyter Notebook 79.83% Python 17.56% Shell 0.79% JavaScript 1.02% HTML 0.80%

long-live-the-battery's Introduction

long-live-the-battery

Predicting total battery cycle life time with TensorFlow 2. We're going to publish a blog post describing the project in-depth soon.

This project is based on the work done in the paper 'Data driven prediciton of battery cycle life before capacity degradation' by K.A. Severson, P.M. Attia, et al., and uses the corresponding data set. The original instructions for how to load the data can be found here.

Setup

We recommend to set up a virtual environment using a tool like Virtualenv.

Clone this repo

git clone https://github.com/dsr-18/long-live-the-battery

and install dependencies.

pip install -r requirements.txt

You can download the processed dataset here and jump to Train Model. If you want to reproduce the data preprocessing step, go ahead with Generate Local Data.

Generate Local Data

Before running the model, generate local data:

  1. Download the original three batch files here into a data directory like this:
long-live-the-battery
├── data
|   ├── 2017-05-12_batchdata_updated_struct_errorcorrect.mat
|   ├── 2018-04-12_batchdata_updated_struct_errorcorrect.mat
|   └── 2017-06-30_batchdata_updated_struct_errorcorrect.mat
  1. Make sure data is empty otherwise. Then from the base directory run
python -m trainer.data_preprocessing

to create a processed_data.pkl file.

  1. Then run
python -m trainer.data_pipeline

to recreate the .tfrecord files.

Train Model

Make sure the .tfrecord files are saved in this structure:

long-live-the-battery
├── data
|   ├── tfrecords
|   |   ├── scaling_factors.csv
|   |   ├── train
|   |   ├── test
|   |   └── secondary_test

To start training the model, run this command from the base directory:

python -m trainer.task

The default is set to three epochs which is okay for testing, but too short to train a reasonably fit model. Use the above command with the --num-epochs flag to set a higher number. To get a list of other parameters, use the --help flag.

To run the model in Google Cloud Platform (team members only):

  1. Make sure you have access to the ion-age project.
  2. Install GCloud SDK.
  3. Run from base directory (with -h to see configurable options):
./train.sh

Follow the output URL to stream logs.

Predict

Every training run saves a TensorBoard logfile and at least one model checkpoint by default in the Graph directory. One way to test your model's performance without writing your own TensorFlow Keras code is to start a local Flask server that serves predictions:

  1. Copy any model from a checkpoints directory within Graph to the server directory.
  2. Rename that model folder to saved_model.
  3. Create sample data to predict on:
python generate_json_samples.py
  1. Go into the server and start it from there:
cd server
python server.py
  1. Now visit "localhost:5000" in your browser and you should see the start page with a prompt to upload battery data in json-format. The site also lets you select the sample data randomly.

long-live-the-battery's People

Contributors

ademfr avatar moxkari avatar rubbedikatz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.