5. Embedded AI — Battery State of Charge using Machine Learning

David Such
13 min readJul 7, 2024

Our first attempt at an ML model was a worse predictor, than a horizontal line through the mean. Don’t panic! We are only half way through the process, and it’s time for the humans to add some value. A lot of articles do this work behind the scenes and present you with a fully fitted model after one run of the training data. We think it is more realistic to present the real picture, and unless you are very lucky, the hyperparameters will need tuning.

Image Created using Midjourney

Hyperparameter Tracking

After you have done a few tuning trials it can be hard to remember what parameters were changed in each trial. To help with this, we have created a dictionary named config , which is used to store all the trial hyperparameters and settings. This dictionary makes it easy to adjust hyperparameters and print them out at the end of the script.

# Define the hyperparameters in a configuration dictionary
config = {
'trial': 1,
'initial_constant_value': 0.01,
'constant_bounds': (0.001, 0.1),
'initial_length_scales': [0.5, 0.25, 1.0],
'length_scale_bounds': (0.01, 1.0),
'max_iter': 15000,
'n_restarts_optimizer': 10,
'cv_folds': 5
}

With each run taking many hours, you don’t want to have to redo a training session because you changed the wrong parameters…

--

--

David Such
David Such

Written by David Such

Reefwing Software · Embedded Systems Engineer · iOS & AI Development · Robotics · Drones · Arduino · Raspberry Pi · Flight Control

No responses yet