No history yet

Machine Learning Fundamentals

Three Ways Machines Learn

Machine learning models learn from data in three primary ways: with a teacher, on their own, or through trial and error. These approaches are known as supervised, unsupervised, and reinforcement learning.

Learning TypeInput DataGoalExample
SupervisedLabeledPredict an outcomeForecasting sales based on past sales data
UnsupervisedUnlabeledDiscover hidden patternsGrouping customers by purchasing behavior
ReinforcementNone (an environment)Maximize a rewardAn AI learning to play chess by winning games

In supervised learning, the model is given labeled data, much like a student studying with an answer key. The goal is to learn the mapping function that turns inputs into the correct outputs. Think of it as learning to identify spam by looking at thousands of emails already marked as "spam" or "not spam."

Unsupervised learning is about finding structure in unlabeled data. The model acts like a detective, looking for clues and connections on its own. It might be used to segment customers into different marketing groups or identify anomalous network activity without being told what constitutes an "attack."

Reinforcement learning involves an "agent" that learns by interacting with an environment. It receives rewards for good actions and penalties for bad ones. Over time, the agent develops a strategy, or policy, to maximize its total reward. This is the same process used to train AIs to master games like Go or control robotic arms.

Supervised Learning Algorithms

Supervised learning is the most common type of machine learning. Let's look at three foundational algorithms used for making predictions with labeled data.

First up is linear regression, a workhorse for predicting continuous values like a house price or a company's future revenue.

The core idea is to find a straight line that best fits the data points. This line represents the relationship between the input variables (features) and the output variable (the target). For a simple case with one input feature (xx) and one output (yy), the relationship is described by this classic formula:

y=β0+β1x+ϵy = \beta_0 + \beta_1x + \epsilon

The algorithm's job is to find the optimal values for β0\beta_0 and β1\beta_1 that minimize the overall error. While powerful for its simplicity and interpretability, linear regression's main limitation is its assumption that the relationship between variables is linear. If the true relationship is curved, the model won't perform well.

Next, we have decision trees. These are versatile algorithms that can be used for both regression (predicting a number) and classification (predicting a category). A decision tree works by splitting the data into smaller and smaller subsets based on a series of questions, like a flowchart.

Lesson image

Imagine a tree trying to decide if you should play tennis. The first question might be, "What is the outlook?" If it's sunny, it might ask, "What is the humidity?" This continues until it reaches a leaf node with a final decision: "Play" or "Don't Play." Their key advantage is that they are easy to visualize and understand. However, a single decision tree can be prone to overfitting, meaning it learns the training data too well, including its noise, and fails to generalize to new, unseen data.

Finally, let's consider Support Vector Machines, or SVMs. This algorithm is typically used for classification problems.

An SVM's goal is to find the best possible dividing line, or hyperplane, that separates data points of different classes. It doesn't just find any line; it finds the one that creates the largest possible margin, or street, between the classes. The data points closest to the hyperplane that define this margin are called support vectors.

By maximizing this margin, the SVM creates a robust decision boundary that is less likely to be influenced by small changes in the data. SVMs are effective in high-dimensional spaces and are memory-efficient because they only use a subset of training points (the support vectors) in the decision function. A key limitation is that they can be computationally expensive to train on very large datasets.

Quiz Questions 1/6

Which type of machine learning involves an agent learning to make decisions by receiving rewards or penalties for its actions?

Quiz Questions 2/6

What is the primary limitation of Linear Regression?

These three algorithms represent different strategies for supervised learning, each with distinct strengths and ideal use cases. Understanding their trade-offs is the first step toward choosing the right tool for a given problem.