Machine Learning: How It Applies to Your Daily Developer Life
What is machine learning? We all have heard about artificial intelligence; also, you would have seen entrance examinations where pattern recognition is used for the evaluation of answer sheets. Machine learning has evolved from artificial intelligence, basically based on learning from collected data that can be used to predict possibilities or outcomes in the future.
There are two definitions of machine learning. An informal definition was given by Arthur Samuel:
A more formal definition was given by Tom Mitchell:
"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 this article, we will study how machine learning plays a role in our day to day life.
We all use emails and often have seen that some mails land into spam or junk folders instead of the inbox. This is a very common example where machine learning is applied. When we do a Bing or a Google search certain, search results are shown higher up the order as compared to the rest; that too is an example where machine learning is applied. The other examples are speller corrections when doing an Internet search. When doing online shopping, we get product recommendations or advertisements based on how other users respond to different products. These are all real life examples of machine learning.
Machine learning can be categorized into two sections, as shown below:
In supervised learning, we have a historical set of results. These results are correct or accurate results. These have fixed input values and a determined output value. In other words, for every value of X, there is a correct value Y.
Examples of supervised learning are plants/animals classifications, real estate prices, stock prices, a patient's medical history, and so on. Supervised learning can be further categorized into the following:
- Regression problems: These can be defined as for every change in the value of X there is a corresponding change in the value of Y. Real estate prices and stock prices can be classified as regression problems because the prediction can be mapped to a continuous function. For example, a smaller house may cost less than a larger house.
- Classification problems: These problems has discrete set of outputs. For example, animals can be classified as herbivorous, carnivorous, or omnivorous.
Unsupervised learning means we have a result set with no pre-defined parameters to be measured against. Let's take a mobile tower that sends data to different mobile devices. The data captured by these towers are huge. These data can be used to study the distribution of load during the day, or they can be used by the mobile operators to launch a new offer, and so on. Unsupervised learning can be something that the search engine uses to do searches by deciphering the words.
Linear Regression Algorithm
We will learn to predict a value of Y based on linear regression. The graph in Figure 1 is plotted based on some dataset.
Figure 1: Predicting a value of Y, based on linear regression
Numerically, it can be represented as (Linear regression with one variable 'x'):
r(x) = θ0 + θ1x
Where θ0 is a bias or intercept and θ1 is the slope. By using this formula, if we plot a graph against the dataset shown in Figure 1, it will be a straight line (as close as possible to the actual values), as shown in Figure 2.
Figure 2: Plotting a straight line from the data in Figure 1
In the preceding formula, the choice of θ0 & θ1 should be such that the difference between Y and r(x) should be minimal. In other words, the straight line r(x) should be able to cover the highest number of Ys. The formula used to calculate θ1, also called the mean square error is:
Jn = 1/2n 2
This is also called the cost function where the previous formula is used to minimize θ 1. The graph plotted by the cost function is a curve as shown in Figure 3:
Figure 3: The cost function curve
The aim is to find a θ1 where the slope is minimum. Once a lowest θ1 is found, this then can be used to plot the linear graph that will help predict the closest outcome (y) for any given value of (x).
In this article, we saw the introduction of machine learning and how machine learning plays a role in our daily life. We also saw how the different mathematical formulas that we learned during school and college applies in our daily life. We saw the different categories of machine learning and looked at the linear regression algorithm to predict output values.