Views
No views yet
RandomForestRegressor architecture optimized for real-time State of Charge (SoC) estimation in Battery Management Systems (BMS). The model is trained on the McMaster LG 18650HG2 dataset, leveraging structural dynamic features to mitigate the classic tree-extrapolation blindspot.1import joblib
2import pandas as pd
3from huggingface_hub import hf_hub_download
4
5# 1. Download components from the Hub
6repo_id = "UNUSUALxd/battery-soc-random-forest"
7model_path = hf_hub_download(repo_id=repo_id, filename="rf_soc_estimator.joblib")
8scaler_path = hf_hub_download(repo_id=repo_id, filename="minmax_scaler.joblib")
9
10# 2. Load into memory
11model = joblib.load(model_path)
12scaler = joblib.load(scaler_path)
13
14# 3. Format input frame (Must match original feature mapping order exactly)
15features_order = [
16 'Voltage', 'Current', 'Temperature', 'Cumulative_Ah', 'dV_dt', 'dI_dt',
17 'V_roll_mean_5', 'V_roll_std_5', 'I_roll_mean_5', 'I_roll_std_5',
18 'V_roll_mean_10', 'V_roll_std_10', 'I_roll_mean_10', 'I_roll_std_10',
19 'V_roll_mean_20', 'V_roll_std_20', 'I_roll_mean_20', 'I_roll_std_20'
20]
21
22# Create your raw DataFrame matching the column ordering above
23# sample_df = pd.DataFrame([your_raw_values], columns=features_order)
24
25# 4. Scale features and run estimator
26# scaled_features = scaler.transform(sample_df)
27# predicted_soc = model.predict(scaled_features)[0]
28# print(f"Estimated SoC: {predicted_soc * 100:.2f}%")