Ziwei Ma
6/15/2021
Learning like intelligence, covers such a broad range of processes that it is difficult to define precisely.
Machine very broadly, that a machine learns whenever it changes its structure, program, or data (based on its inputs or in response to external information) in such a manner that its expected future performance improves.
Machine Learning usually refers to the changes in systems that perform tasks associated with artificial intelligence (AI).
Some tasks cannot be defined well except by example, that is, we might be able to specify input/output pairs but not a concise relationship between inputs and desired outputs.
It is possible that hidden among large piles of data are important relationships and correlations. Machine learning methods can often be used to extract these relationships (data mining).
Human designers often produce machines that do not work as well as desired in the environments in which they are used.
The amount of knowledge available about certain tasks might be too large for explicit encoding by humans.
Environments change over time.
New knowledge about tasks is constantly being discovered by humans.
Statistics
Brain Model
Adaptive Control Theory
Psychological Models
Artificial Intelligence
Evolutionary Models
• Functions
• Logic programs and rule sets
• Finite-state machines
• Grammars
• Problem solving systems
Supervised learning
Unsupervised learning
Label and Feature
Example
An example is a particular instance of data, x. We break examples into two categories:
Model
A model defines the relationship between features and label. Let’s highlight two phases of a model’s life:
Training means creating or learning the model. That is, you show the model labeled examples and enable the model to gradually learn the relationships between features and label.
Inference means applying the trained model to unlabeled examples. That is, you use the trained model to make useful predictions (y’).
Regression vs. classification
A regression model predicts continuous values. For example, regression models make predictions that answer questions like the following:
A classification model predicts discrete values. For example, classification models make predictions that answer questions like the following:
Is a given email message spam or not spam?
Is this an image of a dog, a cat, or a hamster?
For example, the following table shows 5 labeled examples from a data set containing information about housing prices in California:
| housingMedianAge (feature) |
totalRooms (feature) |
totalBedrooms (feature) |
medianHouseValue (label) |
|---|---|---|---|
| 15 | 5612 | 1283 | 66900 |
| 19 | 7650 | 1901 | 80100 |
| 17 | 720 | 174 | 85700 |
| 14 | 1501 | 337 | 73400 |
| 20 | 1454 | 326 | 65500 |
| 15 | 5612 | 1283 | 66900 |
| housingMedianAge (feature) |
totalRooms (feature) |
totalBedrooms (feature) |
|---|---|---|
| 42 | 1686 | 361 |
| 34 | 1226 | 180 |
| 33 | 1077 | 271 |
Background It has long been known that crickets (an insect species) chirp more frequently on hotter days than on cooler days. For decades, professional and amateur scientists have cataloged data on chirps-per-minute and temperature. As a birthday gift, your Aunt Ruth gives you her cricket database and asks you to learn a model to predict this relationship. Using this data, you want to explore this relationship.
Using the equation for a line, you could write down this relationship as follows: \[y=mx+b\] where: - \(y\) is the temperature in Celsius—the value we’re trying to predict. - \(m\) is the slope of the line. - \(x\) is the number of chirps per minute—the value of our input feature. - \(b\) is the y-intercept.
By convention in machine learning, you’ll write the equation for a model slightly differently: \[y'=b+w_1 x_1\] where: - \(y'\) is the temperature in Celsius—the value we’re trying to predict. - \(w_1\) is is the weight of feature 1. Weight is the same concept as the “slope” \(m\) in the traditional equation of a line. - \(x_1\) is a feature (a known input). - \(b\) is bias (the y-intercept), sometimes referred to as \(w_0\).
Although this model uses only one feature, a more sophisticated model might rely on multiple features, each having a separate weight (\(w_1\), \(w_2\), etc.). For example, a model that relies on three features might look as follows: \[y'=b+w_1 x_1+w_2 x_2+w_3 x_3\]
The linear regression models we’ll examine here use a loss function called squared loss (also known as \(L_2\) loss).
Remark Although MSE is commonly-used in machine learning, it is neither the only practical loss function nor the best loss function for all circumstances.
In ML, the majority commonly used methods to reduce loss are interactively proceeded.
Iterative learning might remind you of the “Hot and Cold” kid’s game for finding a hidden object like a thimble. In this game, the “hidden object” is the best possible model. You’ll start with a wild guess (“the values of \(w_1\) is 0”) and wait for the system to tell you what the loss is. Then, you’ll try another guess (“the values of \(w_1\) is 0.5”) and see what the loss is. Aah, you’re getting warmer. Actually, if you play this game right, you’ll usually be getting warmer. The real trick to the game is trying to find the best possible model as efficiently as possible.
Suppose we had the time and the computing resources to calculate the loss for all possible values of \(w_1\). For the kind of regression problems we’ve been examining, the resulting plot of loss vs. \(w_1\) will always be convex. In other words, the plot will always be bowl-shaped, kind of like this:
Convex problems have only one minimum; that is, only one place where the slope is exactly 0. That minimum is where the loss function converges.
Calculating the loss function for every conceivable value of \(w_1\) over the entire data set would be an inefficient way of finding the convergence point. Let’s examine a better mechanism—very popular in machine learning—called gradient descent.
Note: a gradient is a vector, so it has both of the following characteristics: a direction and a magnitude
Note: The gradient always points in the direction of steepest increase in the loss function. The gradient descent algorithm takes a step in the direction of the negative gradient in order to reduce loss as quickly as possible.
As noted, the gradient vector has both a direction and a magnitude. Gradient descent algorithms multiply the gradient by a scalar known as the learning rate (also sometimes called step size) to determine the next point. For example, if the gradient magnitude is 2.5 and the learning rate is 0.01, then the gradient descent algorithm will pick the next point 0.025 away from the previous point.
Hyperparameters are the knobs that programmers tweak in machine learning algorithms. Most machine learning programmers spend a fair amount of time tuning the learning rate.
When the loss function is NOT concave (for complicated model, like neural network), the gradient decent method highly depends on the initial value assignments and only reach to local minimum.
High loss, not a good model (under fit)
Low loss, but still a bad model (over fit)
In modern times, we’ve formalized Ockham’s razor into the fields of statistical learning theory and computational learning theory. These fields have developed generalization bounds–a statistical description of a model’s ability to generalize to new data based on factors such as:
A machine learning model aims to make good predictions on new, previously unseen data. But if you are building a model from your data set, how would you get the previously unseen data? Well, one way is to divide your data set into two subsets:
You could imagine slicing the single data set as follows:
Make sure that your test set meets the following two conditions:
This partitioning enabled you to train on one set of examples and then to test the model against a different set of examples. With two partitions, the workflow could look as follows:
You can greatly reduce your chances of overfitting by partitioning the data set into the three subsets shown in the following figure:
Many machine learning models must represent the features as real-numbered vectors since the feature values must be multiplied by the model weights.