Demystify Machine Learning

2 minute read

Now a days one hears so much about machine learning so I thought I’d illustrate how machines actually learn using one of the simplest forms of machine learning that’s based on a simple data set.

Buying a Car

So I’m looking for a used car however buying a used car is a harrowing experience as one can never be too sure if there getting a good deal on or if it’s just pure daylight robbery.

To remedy this I decide to use machine learning to tell me what price I should pay for a car. Let’s say there’s some free online data for used cars sold in my neighborhood. The date tells me how old the car was and the price it sold for.

what is machine learning.png

If I plot this with the price against how old the car is I get something like this as you can see there is somewhat of a pattern I can now draw a line to approximate how much we should pay for say a seven-year-old car which turns out to be about $17,000.

what is machine learning2.png

Using basic algebra I can write down an equation for the line. Looking at the line the y-intercept or the point at which the line cuts the y-axis is 33 also the slope of the line is about -3 so the equation of this line is y = -3x+33; or in other words the price of the car is equal to -3 multiplied by (age of car) plus 33.

If we can program a computer to read these data points and come up with an equation then given any value of x, which is the age of the car the computer can come up with the price.

Essentially the computer would have “learned” from this data.

How does the computer actually come up with the equation based on this data?

Well first it assumes an arbitrary equation, then for that equation it computes an error term which basically tells it how far it is from the data points. If the error is too high then it adjusts the two parameters the slope and the y-intercept in a way that reduces this error. Then it does it again and again and again until it comes up to a close approximation of the data; then it stops.

what is machine learning3.png

The equation is the model that’s being created. Using this model it can tell the price of the car given the year. And That’s it.

Now the same principle can be extended to add more dimensions to the data such as the car mileage, postcode, car model etc.

So to summarize, the things that matter for any machine learning is:

  • The data: This has to be sufficient.
  • The model: This has to be well chosen.
  • The algorithm: it'll find the parameters of the model.

Hope this helps…