**Simplest Introduction To Machine Learning**

Yet another article on - Introduction To Machine Learning. Believe me, this article is going to be the simplest introduction to the term **Machine Learning**. So, let’s start without wasting our time.

**What is Machine Learning?**

Let’s go through the Wikipedia definition.

**Machine learning** is a field of computer science that gives computers the ability to learn without being explicitly programmed.

Yes, it's a field of computer science. But how does the machine gets the ability to learn and that even without being explicitly programmed.

And we all know that whatever a machine does, it does because it is being explicitly programmed to do so.

So, here the sentence **ability to learn without being explicitly programmed** is very important.

Let’s figure it out how does it get the ability to learn without being explicitly programmed.

Let say you have to write a program to find the value of `y`

in `y = mx+c`

where the values of the constants `m`

and `c`

are already given.

When you provide the values of `x`

to the `mx+c`

, it will give you the value of `y`

.

How will you program it?

```
public class LetsLearnAI {
private static final int m = 10;
private static final int c = 1;
public static int getY(int x){
return (m*x) + c;
}
}
```

Now, you can call that function for the value of `x=10`

like below.

` y = LetsLearnAI.getY(10);`

This way, you get the value of `y`

as `101`

.

Now let’s say someone has given you so many values of `x`

and the corresponding values of `y`

for the given `x`

.

```
x | y
-------
10 | 101
5 | 51
20 | 201
50 | 501
and much more.
```

Then, asked you, what will be the `y`

when `x`

is `30`

?

You will start thinking by seeing the data and try to find some sort of relations and equations between x and y.

After so many hit and trail. You will think that it may be a linear equation `y = mx + c`

with `m = 10`

and `c = 1`

;

Then, you will tell that for `x = 30`

, `y`

will be `301`

.

If the same thing is being done by the machine, we say the machine has learned to find `y`

when we provide a new `x`

. And the machine has learned it from the previous data.

This is **Machine Learning**.

So, how will the machine learn it? We will help the machine to learn it.

Basically, after seeing the data, we will tell the machine that the equation is `y = mx+c`

. But let the machine find the value of `m`

and `c`

based on the data.

First of all, we will initialize `m`

and `c`

with some random value like `2`

and `3`

and then define an equation like below:

` yPred = (m*x) + c;`

`yPred`

means the predicted value of `y`

by the machine.

Then, we will compare it with the true value of `y`

from the given data, we will see that how much it differ from the true value of `y`

, then we will provide a way to machine to modify the values of `m`

and `c`

so that the `yPred`

gets closer to the true value of `y`

.

The machine will iterate it again and again until it finds `m = 10`

and `c = 1`

.

The difference between the predicted and the true value, we call it as an error.

Basically, the machine needs to minimize the error as much as it can.

Think of `y^`

as a predicted value and `y`

as a true value. Here, we take the difference between both(`y^`

and `y`

) and square it because the error can be -ve also. Then we add all the errors, after that, we take the square root (because we had squared it earlier) and finally divide it by `N`

(finding mean because we had added all the errors earlier). So, this is known as the **mean squared error (MSE)**.

The error should be close to zero after considering all the values of `yPred`

and the true values of `y`

.

So, we program for the error function and the minimizer so that the machine can minimize the error and find the correct values of `m`

and `c`

.

Now, the machine knows the values of `m`

and `c`

, it can easily tell you the value of `y`

for any new `x`

.

This was a very simple example for understanding. In some other case, after seeing the data, if we think that it’s going to be parabolic then, we define `y`

as below:

` y = (a*x*x) + (b*x) + c;`

Then, we try to find the values of `a`

, `b`

and `c`

.

Then, we can predict any `y`

from the given `x`

.

This way we help the machine in learning the value of the constants in the equation.

Basically, we help the machine to find the relation between `x`

and `y`

with some equations (we help in defining the equation as linear or polynomial by looking at the data from our experience).

For a human, it is tough to find the correct values of those constants as there are so many calculations involved like calculating error, minimizing it and iterating it till the error reaches very close to zero. So, we have given this task to the machine.

This way the machine learning can be applied to any problem that we want to solve.

Machine Learning works on the same analogy on which our brain works.

When a human sees a picture, how he/she can say that this picture consists of a bird, a person or something else. He/She can say because in the past he/she has seen something like those and had learned that this is a bird, a person or something else. So he/she can recognize in the future.

Similarly, a machine is trained to do so but by some equations as the machine can only learn it through some numbers.

This is **Machine Learning**.

**Also, Let’s become friends on** **Twitter,** **Linkedin,** **Github,** **Quora, and Facebook.**