0% found this document useful (0 votes)
64 views15 pages

Machine Learning Guide 2017

This document discusses machine learning concepts including: 1) Supervised learning involves predicting outputs given labeled input data, including linear regression to model continuous variables and logistic regression for discrete classification tasks. 2) Unsupervised learning discovers hidden patterns in unlabeled data through methods like k-means clustering. 3) Models are represented using variables like x (inputs) and y (targets), and training algorithms optimize parameters to learn the relationship between x and y from labeled examples.

Uploaded by

Alex hackingyou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views15 pages

Machine Learning Guide 2017

This document discusses machine learning concepts including: 1) Supervised learning involves predicting outputs given labeled input data, including linear regression to model continuous variables and logistic regression for discrete classification tasks. 2) Unsupervised learning discovers hidden patterns in unlabeled data through methods like k-means clustering. 3) Models are represented using variables like x (inputs) and y (targets), and training algorithms optimize parameters to learn the relationship between x and y from labeled examples.

Uploaded by

Alex hackingyou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

MACHINE LEARNING

SUMMER OF SCIENCE - 2017


IIT BOMBAY

By
Shubham Jain

MENTOR
Saurabh Kumar
CONTENT

1) INTRODUCTION

2) SUPERVISED AND UNSUPERVISED LEARNING

3) MODEL REPRESENTATION

4) LINEAR REGRESSION

5) LOGISTIC REGRESSION

6) REGULARIZATION

7) NEURAL NEWORKS

8) UNSUPERVISED LEARNING
a) K-MEANS ALGORITHM

9) CONCLUSION

10) BIBLIOGRAPHY
INTRODUCTION

What is machine learning? Machine learning is the science of getting computers to act
without being explicitly programmed. In the past decade, machine learning has given
us self-driving cars, practical speech recognition, effective web search, and a vastly
improved understanding of the human genome. Machine learning is so pervasive
today that you probably use it dozens of times a day without knowing it. Each time
you do a web search on Google or Bing, that works so well because their machine
learning software has figured out how to rank what pages. When Facebook or Apple's
photo application recognizes your friends in your pictures, that's also machine
learning. Each time you read your email and a spam filter saves you from having to
wade through tons of spam, again, that's because your computer has learned to
distinguish spam from non-spam email. So, that's machine learning. There's a science
of getting computers to learn without being explicitly programmed. Many researchers
also think it is the best way to make progress towards human-level AI.
Two definitions of Machine Learning are offered. Arthur Samuel described it as: "the
field of study that gives computers the ability to learn without being explicitly
programmed." This is an older, informal definition.

Tom Mitchell provides a more modern definition: "A computer program is said to
learn from experience E with respect to some class of tasks T and performance
measure P, if its performance at tasks in T, as measured by P, improves with
experience E."

In general, any machine learning problem can be assigned to one of two broad
classifications:
• Supervised learning
• Unsupervised learning.
Supervised Learning
In supervised learning, we are given a data set and already know what our correct output
should look like, having the idea that there is a relationship between the input and the
output.
Supervised learning problems are categorized into "regression" and "classification"
problems. In a regression problem, we are trying to predict results within a continuous
output, meaning that we are trying to map input variables to some continuous function.
In a classification problem, we are instead trying to predict results in a discrete output. In
other words, we are trying to map input variables into discrete categories.

Example :
(a) Regression - Given a picture of a person, we have to predict their age on the basis of
the given picture
(b) Classification - Given a patient with a tumor, we have to predict whether the tumor is
malignant or benign.

Unsupervised Learning
Unsupervised learning allows us to approach problems with little or no idea what our
results should look like. We can derive structure from data where we don't necessarily
know the effect of the variables. We can derive this structure by clustering the data
based on relationships among the variables in the data. With unsupervised learning
there is no feedback based on the prediction results.

Example :
(a) Clustering: Take a collection of 1,000,000 different genes, and find a way to
automatically group these genes into groups that are somehow similar or related by
different variables, such as lifespan, location, roles, and so on.
Model Representation
To establish notation for future use, we’ll use x(i) to denote the “input” variables, also
called input features, and y(i) to denote the “output” or target variable that we are
trying to predict. A pair (x(i),y(i)) is called a training example, and the dataset that
we’ll be using to learn—a list of m training examples (x(i),y(i));i=1,...,m—is called a
training set. Note that the superscript “(i)” in the notation is simply an index into the
training set, and has nothing to do with exponentiation. We will also use X to denote
the space of input values, and Y to denote the space of output values.

To describe the supervised learning problem slightly more formally, our goal is, given
a training set, to learn a function h : X → Y so that h(x) is a “good” predictor for the
corresponding value of y. For historical reasons, this function h is called a hypothesis.
Seen pictorially, the process is therefore like this:

When the target variable that we’re trying to predict is continuous, we call the
learning problem a regression problem. When y can take on only a small number of
discrete values, we call it a classification problem.
Linear Regression
Cost Function

We can measure the accuracy of our hypothesis function by using a cost function. This takes
an average difference (actually a fancier version of an average) of all the results of the
hypothesis with inputs from x's and the actual output y's.

To break it apart, it is 12 x¯ where x¯ is the mean of the squares of hθ(xi)−yi , or the difference
between the predicted value and the actual value.
This function is otherwise called the "Squared error function", or "Mean squared error".

Gradient Descent

So we have our hypothesis function and we have a way of measuring how well it fits into the data.
Now we need to estimate the parameters in the hypothesis function. That's where gradient descent
comes in.
The gradient descent algorithm is:

repeat until convergence:

where j=0,1 represents the feature index number.


At each iteration j, one should simultaneously update the parameters θ1,θ2,...,θn.
If we put θ0 on the x axis and θ1 on the y axis, with the cost function on the vertical z axis. The points on
our graph will be the result of the cost function using our hypothesis with those specific theta parameters.
We will know that we have succeeded when our cost function is at the very bottom of the pits in our
graph, i.e. when its value is the minimum. The way we do this is by taking the derivative (the tangential
line to a function) of our cost function. The slope of the tangent is the derivative at that point and it will
give us a direction to move towards. We make steps down the cost function in the direction with the
steepest descent. The size of each step is determined by the parameter α, which is called the learning rate.

A smaller α would result in a smaller step and a larger α results in a larger step. The direction in which
the step is taken is determined by the partial derivative of J(θ0,θ1). Depending on where one starts on the
graph, one could end up at different points.
While applying Gradient descent for multiple variables, we can speed up gradient descent by
having each of our input values in roughly the same range. This is because θ will descend quickly
on small ranges and slowly on large ranges, and so will oscillate inefficiently down to the optimum
when the variables are very uneven.
The way to prevent this is to modify the ranges of our input variables so that they are all roughly
the same. Ideally:

−1 ≤ x(i) ≤ 1
The goal is to get all input variables into roughly one of these ranges, give or take a few.

Two techniques to help with this are feature scaling and mean normalization. Feature scaling
involves dividing the input values by the range (i.e. the maximum value minus the minimum
value) of the input variable, resulting in a new range of just 1. Mean normalization involves
subtracting the average value for an input variable from the values for that input variable resulting
in a new average value for the input variable of just zero. To implement both of these techniques,
adjust your input values as shown in this formula:

Where μi is the average of all the values for feature (i) and si is the range of values (max - min),
or si is the standard deviation.

Normal Equation

Gradient descent gives one way of minimizing J. There is a second way of doing so, this time
performing the minimization explicitly and without resorting to an iterative algorithm. In the
"Normal Equation" method, we will minimize J by explicitly taking its derivatives with respect to
the θj ’s, and setting them to zero. This allows us to find the optimum theta without iteration.
The normal equation formula is given below:

θ = (XTX)−1XTy

There is no need to do feature scaling with the normal equation.


Classification

In classification our hypotheses hθ(x) is of the form so as to satisfy 0 ≤ hθ(x) ≤ 1. This is


accomplished by plugging θTx into the Logistic Function.

Our new form uses the "Sigmoid Function," also called the "Logistic Function":

hθ(x) will give us the probability that our output is 1. For example, hθ(x)=0.7 gives us a
probability of 70% that our output is 1. Our probability that our prediction is 0 is just the
complement of our probability that it is 1 (e.g. if probability that it is 1 is 70%, then the
probability that it is 0 is 30%).

Cost Function

Our cost function for logistic regression looks like:

We can compress our cost function's two conditional cases into one case:
We can fully write out our entire cost function as follows:

A vectorized implementation is:

Gradient Descent

A vectorized implementation is:


Overfitting and Underfitting

Underfitting, or high bias, is when the form of our hypothesis function h maps poorly to the
trend of the data. It is usually caused by a function that is too simple or uses too few features.
At the other extreme, overfitting, or high variance, is caused by a hypothesis function that fits
the available data but does not generalize well to predict new data. It is usually caused by a
complicated function that creates a lot of unnecessary curves and angles unrelated to the
data.

This terminology is applied to both linear and logistic regression. There are two main
options to address the issue of overfitting:

1) Reduce the number of features:

• Manually select which features to keep.


• Use a model selection algorithm (studied later in the course).

2) Regularization

• Keep all the features, but reduce the magnitude of parameters θj.
• Regularization works well when we have a lot of slightly useful features.

We could regularize all of our theta parameters as :

The λ, or lambda, is the regularization parameter. It determines how much the costs of our
theta parameters are inflated.
Using the above cost function with the extra summation, we can smooth the output of our
hypothesis function to reduce overfitting. If lambda is chosen to be too large, it may smooth
out the function too much and cause underfitting.

We can apply regularization to both linear regression and logistic regression.


Regularized Linear Regression

Gradient Descent

We will modify our gradient descent function to separate out θ0 from the rest of the parameters
because we do not want to penalize θ0.

The term (λ/m)*θj performs our regularization.

Regularized Logistic Regression

Cost Function

We can regularize our cost function equation by adding a term to the end:
Neural Networks

Let's examine how we will represent a hypothesis function using neural networks. At a
very simple level, neurons are basically computational units that take inputs (dendrites)
as electrical inputs (called "spikes") that are channeled to outputs (axons). In our model,
our dendrites are like the input features x1…xn, and the output is the result of our
hypothesis function. In this model our x0 input node is sometimes called the "bias unit." It
is always equal to 1. In neural networks, we use the same logistic function as in
classification, , yet we sometimes call it a sigmoid (logistic) activation function. In
this situation, our "theta" parameters are sometimes called "weights".

Our input nodes (layer 1), also known as the "input layer", go into another node (layer 2),
which finally outputs the hypothesis function, known as the "output layer".
We can have intermediate layers of nodes between the input and output layers called the
"hidden layers."
In this example, we label these intermediate or "hidden" layer nodes a02…an2 and call
them "activation units."

If we had one hidden layer, it would look like:

The values for each of the "activation" nodes is obtained as follows:

If network has sj units in layer j and sj+1 units in layer j+1, then Θ(j) will be of dimension
sj+1×(sj+1).
Cost Function

Let's first define a few variables that we will need to use:

• L = total number of layers in the network


• sl = number of units (not counting bias unit) in layer l
• K = number of output units/classes

For neural networks, cost function is going to be slightly more complicated:

Backpropagation Algorithm

"Backpropagation" is neural-network terminology for minimizing our cost function, just like
what we were doing with gradient descent in logistic and linear regression. Our goal is to
compute:
minΘJ(Θ)

Training a Neural Network

• Randomly initialize the weights


• Implement forward propagation to get hΘ(x(i)) for any x(i)
• Implement the cost function
• Implement backpropagation to compute partial derivatives
• Use gradient checking to confirm that your backpropagation works. Then disable gradient
checking.
• Use gradient descent or a built-in optimization function to minimize the cost function
with the weights in theta.
UNSUPERVISED LEARNING

Unsupervised learning is contrasted from supervised learning because it uses an unlabeled


training set rather than a labeled one.
In other words, we don't have the vector y of expected results, we only have a dataset of features
where we can find structure.
Clustering is good for:

• Market segmentation
• Social network analysis
• Organizing computer clusters
• Astronomical data analysis

K-Means Algorithm

The K-Means Algorithm is the most popular and widely used algorithm for automatically grouping
data into coherent subsets.
• Randomly initialize two points in the dataset called the cluster centroids.
• Cluster assignment: assign all examples into one of two groups based on which cluster centroid
the example is closest to.
• Move centroid: compute the averages for all the points inside each of the two cluster centroid
groups, then move the cluster centroid points to those averages.
• Re-run (2) and (3) until we have found our clusters.

Our main variables are:

• K (number of clusters)
• Training set x(1),x(2),…,x(m)
• Where x(i)∈Rn

The algorithm:
CONCLUSION

• These days, machine learning techniques are being widely used to solve real-world problems
by storing, manipulating, extracting and retrieving data from large sources. S
• Machine Learning (ML) methods provide algorithmic models for an unknown mapping
between predictor and outcome variables.
• ML techniques are differently motivated, the goal is to forecast the outcome with acceptable
accuracy, to be transferable to new datasets.
• In Machine learning, every technique has its own assumptions and constraints, advantages
and limitations.

We have a simple overview of some techniques and algorithms in machine learning. Furthermore,
there are more and more techniques by which we can apply machine learning to a solution for our
problem.

BIBLIOGRAPHY

• https://www.coursera.org/learn/machine-learning
• http://cs229.stanford.edu/materials.html
• Pattern Recognition and Machine Learning - Christopher M. Bishop

Suggested readings
• Introduction to Machine Learning - Alex Smola and S.V.N. Vishwanathan
• The Elements of Statistical Learning - Trevor Hastie , Robert Tibshirani and Jerome Friedman

You might also like