## DEV Community is a community of 894,881 amazing developers

We're a place where coders share, stay up-to-date and grow their careers. # 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:

``````#!/usr/bin/python3
import numpy as np
import pylab as pl
from sklearn import svm

np.random.seed(0)

X = np.r_[np.random.randn(100, 2) - [2, 2], np.random.randn(100, 2) + [2, 2]]
Y = *100 +*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?

### Training

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')
clf.fit(X, Y)
``````

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

### Prediction

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.