Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Machine Learning explained for beginners
petercour
petercour

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:

#!/usr/bin/python3import numpy as npimport pylab as plfrom sklearn import svmnp.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
Enter fullscreen modeExit fullscreen mode

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)
Enter fullscreen modeExit fullscreen mode

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:

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More frompetercour

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp