Python Refresher
Basics of Machine Learning
Machine Learning (ML) is a subfield of Artificial Intelligence where computers learn from data without being explicitly programmed.
The Intuition — Learning Like a Human
Think about how you learned to identify an apple. Your parents didn't give you a rulebook: "If object is round, and red or green, and has a stem, it is an apple."
Instead, they pointed to dozens of apples over time and said, "Apple." Eventually, your brain extracted the underlying pattern.
Machine Learning works the same way. Instead of writing if/else rules, we feed the computer a massive amount of data and let algorithms find the patterns.
How Is This Different from Regular Programming?
Traditional Programming:
- You write the Rules (the logic/algorithm).
- You input the Data.
- The computer outputs the Answers.
Machine Learning:
- You input the Data.
- You input the known Answers (Labels).
- The computer outputs the Rules (The Model).
Once you have "The Model", you can deploy it to an ESP32. You then feed it new Data, and it applies those Rules to predict the new Answers.
Types of Machine Learning
- Supervised Learning: The data is labeled. (e.g., "This image is a cat. This image is a dog."). You train the model to predict the label for new, unseen data. This is what we use most in Edge AI.
- Unsupervised Learning: The data is not labeled. The algorithm tries to find hidden structures or clusters in the data.
- Reinforcement Learning: An agent learns to perform actions in an environment to maximize a reward (like a computer learning to play chess).
The ML Pipeline
When building an ML application, you generally follow these steps:
- Data Collection: Gathering raw data (e.g., recording accelerometer data for 10 minutes while walking, then 10 minutes while running).
- Data Preprocessing: Cleaning the data, handling missing values, and scaling it.
- Splitting the Data: Dividing your data into a Training Set and a Testing Set.
- Training the Model: Feeding the Training Set into an algorithm so it can learn.
- Evaluation: Testing the model against the Testing Set to see how accurate it is on data it has never seen before.
- Deployment: Converting the model to a format like TensorFlow Lite and flashing it to a microcontroller.
Key Terms Explained Simply
- Model: The mathematical representation of what the algorithm has learned. Think of it as a highly complex formula.
- Feature: An individual measurable property of the phenomenon being observed. (e.g., Temperature, X-axis acceleration).
- Label: The "answer" we want the model to predict. (e.g., "Walking", "Running", "Idle").
- Epoch: One complete pass through the entire training dataset.
- Overfitting: When a model memorizes the training data perfectly but performs terribly on new data. It learned the noise, not the underlying pattern.
In the next section, we look at Deep Learning, a specific type of Machine Learning powered by Neural Networks.

