My Machine Learning notes — Week 1

Kalyan Dechiraju
3 min readJul 29, 2018

--

Follow the series here.

Machine Learning can be broadly classified into Supervised Learning and Unsupervised Learning.

Supervised Learning

As the name suggests, the way of teaching machine with supervision. The machine is fed with some labelled data set (training data) and is asked to predict values based on that data. There are two types of Supervised Learning Algorithms.

Regression Algorithm

In this mode of supervised learning, the data set is given to the algorithm and is expected to predict a concrete value. The well known example is the prediction of House pricing. Based on the historical data of the prices, the future value is predicted.

Classification Algorithm

This algorithm analyses the data set and predicts into which category a particular case fall into. Consider the example of marking an email as spam or not spam based on the sample emails which are already labelled.

Unsupervised Learning

The type of learning where the data set is not classified or informative. The task of the algorithm is to specify into which cluster a particular data point falls into. A famous example is Google News. It segregates all the news sources from the internet and groups same news from different sources into one.

To simply put, a machine learning algorithm is something that learns and a computer program is said to learn:

  • from experience E
  • for some task T
  • on some performance measure P

if it’s performance on T, as measured by P, improves with experience E.

Lets under the above statement with an example. A weather prediction algorithm should learn from historical weather data (E) to predict weather in future (T) with a good probability of correctness (P).

Let’s begin with Supervised Learning.

Linear Regression (with one variable)

Let’s continue with the example of housing price prediction with the historical data of prices as training data. We will be feeding the training data set to the regression algorithm and it should predict the future price. The data set is the price based on the area of the house (only one feature).

Training data set: The data set that is used to train the algorithm

Consider the below notation for our further examples.

If the data set is plotted on scattered plot, it will look like this.

https://www.coursera.org/learn/machine-learning/supplement/ExY6Z/lecture-slides

X-axis is the area of the house in square foot and Y-axis is the price of the house in $1000 scale. The green line drawn is our hypothesis function that our algorithm supposed to generate.

https://www.coursera.org/learn/machine-learning/supplement/ExY6Z/lecture-slides

From the graph above, the linear equation will be like

y = mx + c

where y is output for input x, m is the slope and c is the y-intercept.

Skipping the math (that I cannot type on medium), the hypothesis function will be of the below form.

h(x) = c1 + c2*x => c1 and c2 are the parameters of the model.

Our goal here is to choose c1 and c2 so that our hypothesis function h(x) is close to y (the actual value from the training data) for a training example of (x, y).

To put this mathematically, we have to minimise the square of the distance between prediction h(x) and actual value y. So what we are trying to do is minimise the error. This is called Cost Function in machine learning terminology.

Cost Function

If we can minimise this cost function, we can arrive at a best possible solution of predicting the future pricing of the houses.

That’s it for this week. To be continued…

Follow this series here: My Machine Learning Notes

--

--

Kalyan Dechiraju

Mobile and Web Developer at Adobe, excited about the possibilities of Gen AI. I love traveling and finding inspiration from different cultures.