Hello. I'm a beginner. I'm thinking of doing machine learning with a certain service (a matching service for people who can take a picture and someone who wants to take a picture), and I'm investigating.
As a test, I'll solve the first question of this.
http://next.rikunabi.com/tech/docs/ct_s03600.jsp?p=002315
It's a supervised learning problem. Try using SVM as in the example answer on the above page. For the library, I tried using scikit-learn.
http://scikit-learn.org/stable/index.html
If you just want to use SVM, there seems to be other libraries, but scikit-learn is good ~ There are many people who say something like that, so I tried using it.
svmtest.py
# -*- coding: utf-8 -*-
from sklearn.svm import LinearSVC
import numpy as np
#Training data
data_training_tmp = np.loadtxt('CodeIQ_auth.txt', delimiter=' ')
data_training = [[x[0], x[1]] for x in data_training_tmp]
label_training = [int(x[2]) for x in data_training_tmp]
#Test data
data_test = np.loadtxt('CodeIQ_mycoins.txt', delimiter=' ')
#Learning
estimator = LinearSVC(C=1.0)
estimator.fit(data_training, label_training)
#I'll predict
label_prediction = estimator.predict(data_test)
print(label_prediction)
[1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 1]
The example page has the answer in R, but scikit-learn was almost the same.
It seems that other classifiers can be used in the same way. Very good!
Transcendental reference site http://sucrose.hatenablog.com/entry/2013/05/25/133021
I don't really know if I have to check the accuracy of the classifier before making predictions with unknown data. It is necessary to confirm. I mean, I have to tune the parameters as well.
I tried it for a while, but I didn't feel that I was tuning because the data for learning was too small or too easy to verify, or even if I changed the parameters, it hit almost 100%.
I will do it with another data.
It's over today
Recommended Posts