DEV Community

Cover image for Machine Learning explained for beginners

Posted on

Machine Learning explained for beginners

So from a very simple view. How does classification work in Machine Learning? What does it mean when an algorithm learns?

In computers, data is the most important thing. Without data, the computer becomes useless. Many companies have become data hoarders. That data is used to feed algorithms.

Those algorithms then make decisions about society, politics and your personal life.

Yes, the machines are taking over.

Bits and bytes

So start with data. If you are a not a zillion dollar corporation, chances is you don't have a lot of data at hand.

Without data, you can not make useful Machine Learning programs. So data is a very valuable asset to companies.

So you can use predefined data sets or random data. Random? yep:

import numpy as np
import pylab as pl
from sklearn import svm


X = np.r_[np.random.randn(100, 2) - [2, 2], np.random.randn(100, 2) + [2, 2]]
Y = [0]*100 +[1]*100

Yes, all in Python. (Why Python for Machine Learning).

So all this does is create random pairs (X,Y). You may remember from math class that you can create plots with (X,Y) pairs

So these are data points (X,Y). An algorithm then needs to classify.
How can it classify with this data?


It can't, you first needs to divide the data points in two groups.

Many algorithms use a training phase. That's when the algorithm gets example input: data points and classes.

Scientists call that "supervised learning training data set". So if you see that term, it means "data points and classes".

It means that after you collect data, you need to give every record a label/class. Ok, then feed it into the algorithm:

clf = svm.SVC(kernel='linear'), Y)

Just like that. The first line loads an algorithm named svm. The second line trains the algorithm with the given data.


Now if you have a new measurement, a new point, it falls somewhere on the plane. Then you can simply see if it's on the blue class or brown class.

That "seeing" is called predicting. Seeing works as long as it's a 2 dimensional plane. If it's gets 4 dimensional or 12 dimensional, it becomes impossible to see.

Related links:

Top comments (0)