No history yet

Introduction to Machine Learning

What Is Machine Learning?

Machine learning is a way of teaching computers to find patterns. Instead of writing explicit instructions for every possible scenario, we give the computer data and let it figure out the rules on its own.

Think about how you learned to identify a cat. You weren't given a list of rules like "if it has pointy ears, whiskers, and fur, it's a cat." Instead, you saw many examples of cats. Your brain learned to recognize the common features. Machine learning works in a similar way. An algorithm sifts through thousands of cat photos, learning the patterns that define a cat so it can identify one in a new picture.

The goal is for the computer to learn from experience, just like humans do, and make decisions or predictions based on what it has learned.

Two Main Flavors of Learning

Machine learning comes in a few different styles, but two of the most common are supervised and unsupervised learning. The main difference between them is the kind of data they use to learn.

Supervised Learning

Supervised learning is like studying with flashcards. Each card has a question (the input) and an answer (the output). The algorithm learns by looking at these labeled examples one after another.

For instance, if you want to predict a house's price, you'd give the model a dataset of houses where you already know the price. The data would include features like square footage, number of bedrooms, and location, along with the final sale price for each house. The model learns the relationship between these features and the price.

There are two main types of supervised learning tasks:

  • Regression: This is for predicting a continuous numerical value. Predicting a house price, forecasting temperature, or estimating the number of sales next quarter are all regression problems. A common algorithm for this is Linear Regression.
  • Classification: This is for predicting a category. Is this email spam or not spam? Is this tumor malignant or benign? These are classification problems because the answer is one of a fixed set of options. Logistic Regression and Decision Trees are popular classification algorithms.

Unsupervised Learning

Unsupervised learning is more like being thrown into a room full of jumbled items and being asked to sort them. There are no labels or answers provided. The algorithm has to look at the data and find its own structure.

Imagine you have a list of all your customers and their purchasing habits. An unsupervised learning algorithm could automatically group them into segments, like "frequent shoppers," "bargain hunters," and "weekend visitors," without you telling it what to look for. This task of creating groups is called clustering.

  • Clustering: This is the most common unsupervised task. It involves grouping data points so that points in the same group are more similar to each other than to those in other groups. The K-Means algorithm is a classic example of a clustering method.
Lesson image

Data and Model Performance

No matter the approach, data is the fuel for any machine learning model. The quality and quantity of your data directly impact how well your model can learn. We typically split our data into two main piles: a training set and a testing set.

The training set is what the model learns from. It's the collection of examples, like the cat photos or house price data. The testing set is held aside and used to evaluate the model after it has been trained. This helps us see how well it performs on new, unseen data, which is its real purpose.

The goal is to create a model that generalizes well, meaning it can make accurate predictions on data it has never seen before. Two common pitfalls can prevent this: overfitting and underfitting.

  • Underfitting occurs when a model is too simple to capture the underlying patterns in the data. It performs poorly on both the training and testing data. It's like trying to draw a map of a city using only a single straight line.
  • Overfitting is the opposite. The model learns the training data too well, memorizing not just the patterns but also the noise and random fluctuations. When it sees new data, it can't make accurate predictions because it's too specific to what it was trained on. It's like a student who memorizes the answers to a practice test but doesn't understand the concepts, so they fail the real exam.

Finally, how do we know if a model is any good? We use evaluation metrics. For a classification model, a common metric is accuracy, which measures the percentage of correct predictions. For a regression model predicting house prices, we might use Mean Absolute Error, which tells us, on average, how far off our price predictions were from the actual sale prices.

These metrics give us a concrete score to help us compare different models and find the one that strikes the right balance between being too simple and too complex.

Quiz Questions 1/5

What is the primary difference between supervised and unsupervised machine learning?

Quiz Questions 2/5

An e-commerce company wants to build a model that predicts whether a customer will purchase an item in their shopping cart. What type of machine learning problem is this?