4. Embedded AI — Battery State of Charge using Machine Learning
How accurate is Machine Learning (ML), compared to a lookup table with interpolation, when predicting a batteries State of Charge (SOC)? In this part we train our model using Gaussian Process Regression and evaluate the results. Check out Part 3 if you want to know how we defined the problem, located training data, preprocessed the data, and selected an appropriate model. Part 5 will cover evaluation, tuning, and testing, of our model.
Step 4 — Train the Model
The first thing we want to establish is that we can read the preprocessed data that we saved in step 2 of Part 3. This is a Python script that loads the CSV training and test files, then plots the SOC for the training data and the test data at 25 degrees C.
import os
import pandas as pd
import matplotlib.pyplot as plt
# Define the file paths
preprocessed_folder = os.path.expanduser("~/Documents/GitHub/Embedded-AI/data/LGHG2@n10C_to_25degC/preprocessed")
train_file = os.path.join(preprocessed_folder, 'resampled_training_data.csv')
test_file_25deg = os.path.join(preprocessed_folder, 'resampled_test_data_25degC.csv')
# Load the training and test data
train_df = pd.read_csv(train_file)
test_df_25deg = pd.read_csv(test_file_25deg)
# Plot the SOC for the training data
plt.figure(figsize=(12, 6))…