Machine Learning explained for beginners
Tags: machinelearning
Published: 2019-07-11 14:26:41

---
title: Machine Learning explained for beginners
published: true
description: machine learning
tags: machine learning
cover_image: https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fleaptitude.files.wordpress.com%2F2016%2F12%2Fkristi.png&f=1
---
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.

<img src="https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fs3lab.deusto.es%2Fwp-content%2Fuploads%2F2014%2F10%2FAll-Your-Data-Are-Belong-To-Us-S3lab.jpg&f=1">

### 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.

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.imgflip.com%2Fs03p0.jpg&f=1">

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 = [0]*100 +[1]*100

Yes, all in Python. (<a href="http://pythonbasics.org/why-python-for-machine-learning/">Why Python for Machine Learning</a>).

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

![](https://thepracticaldev.s3.amazonaws.com/i/zfkr3oe7tgeapq9j355f.png)

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.

![](https://thepracticaldev.s3.amazonaws.com/i/f7oin3bxzcrfbb5syszz.png)

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".

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7btOXSkRujwwVueI%2Fgiphy.gif&f=1">

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.

Related links:
* <a href="https://scikit-learn.org/stable/index.html">The sklearn module</a>
* <a href="https://gumroad.com/l/MnRYU">Machine Learning Beginners Course and Examples</a>
* <a href="https://pythonprogramminglanguage.com/python-machine-learning/">Machine Learning articles</a>               
* <a href="https://pythonprogramminglanguage.com/What-is-supervised-learning/">What is Supervised Learning</a>
* <a href="https://pythonbasics.org/why-python-for-machine-learning/">Why Python for Machine Learning</a>
* <a href="https://pythonbasics.org/machine-learning-classifier/">Machine Learning Classifier</a>