You are browsing as a guest. Sign up (or log in) to start making projects!

52m logged

i’m back from holiday and man I must say, I missed this, today I must say I was kinda lazy with it right I’ve just come back from being in nature now I must do this? Yeah bro chalk it. Anyhow Deepseek pretty much made the core of the ML Python script which waits for the CSV file the ESP32 generates throughout the day which contains timestamps voltage frequency as well as the outage label (AC on or off) auto cleans the supposed Data from raw numbers to multiple trained models compares them and saves the best one. Nerd mode here btw. when the csv file is detected it uses python’s time and os modules as well as pandas for reading since I might change the format later the script asks for timestamp voltage frequency and label then it does the data cleaning it removes all physically impossible values (voltage must be between 50V and 300V and frequency must be between 45Hz and 65Hz) anything outside those ranges is considered as sensor faults and is dropped and removed. raw sensor readings alone aren’t enough the models need “clues” the script auto makes dozens of features from voltage & frequency (Rolling averages (last 5, 10, 30 samples) – smooths noise and shows trends, Rolling standard deviation – how unstable the signal is, Rolling min / max – worst-case recent values, Difference (rate of change) – how fast voltage is dropping/rising, Lag features – what the value was 1, 2, 3 seconds ago) all these assist in detecting patterns used pandas rolling and shift operations NumPy just chilling in the background. The data is split into two sets: Training set (80%) the model learns from this, Test set (20%) used to evaluate the model on data its never seen. This all prevents “cheating” and gives a more realistic performance estimate scikit-learn is used to handle this. After that the script trains four different machine learning models: Random Forest, XGBoost, LightGBM, and Extra Trees. For each model it uses Optuna to auto-tune hyperparameters like number of trees, tree depth, and learning rate, trying lots of combinations to find the best settings. Then every model gets tested on the 20% hold-out data using metrics like accuracy, precision, recall, and F1 score. The model with the highest F1 score wins and gets saved as best_model.joblib in the models folder along with a feature_names.json file and a latest_report.txt. The whole script keeps watching the incoming_data folder every 5 seconds and whenever a new CSV lands it re-runs the entire pipeline so the prediction model continuously improves without me lifting a finger. This means by the time I have real ESP32 outage logs the system will already be ready to learn my home’s power signature and get smarter every day.

0
2

Comments 0

No comments yet. Be the first!