Try machine learning with scikit-learn SVM

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.

problem

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.

I will try it for the time being

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

By the way?

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

Try machine learning with scikit-learn SVM
Try machine learning with Kaggle
Try SVM with scikit-learn on Jupyter Notebook
Multi-class SVM with scikit-learn
[Python] Easy introduction to machine learning with python (SVM)
Machine learning learned with Pokemon
Try deep learning with TensorFlow
Machine learning with Python! Preparation
Try Deep Learning with FPGA
Machine learning Minesweeper with PyTorch
Beginning with Python machine learning
[Machine learning] Understanding SVM from both scikit-learn and mathematics
Easy machine learning with scikit-learn and flask ✕ Web app
Try to predict forex (FX) with non-deep machine learning
Practical machine learning with Scikit-Learn and TensorFlow-TensorFlow gave up-
[Machine learning] Start Spark with iPython Notebook and try MLlib
Try Deep Learning with FPGA-Select Cucumbers
Reinforcement learning 13 Try Mountain_car with ChainerRL.
[Machine learning] Try studying decision trees
Build a machine learning scikit-learn environment with VirtualBox and Ubuntu
Machine learning ① SVM (Support Vector Machine) Summary
Machine learning with python (1) Overall classification
Try deep learning with TensorFlow Part 2
Machine learning beginners try linear regression
Machine learning
[Machine learning] Try studying random forest
Try to predict if tweets will burn with machine learning
Try Common Representation Learning with chainer
Quantum-inspired machine learning with tensor networks
Get started with machine learning with SageMaker
"Scraping & machine learning with Python" Learning memo
[Machine learning] Try running Spark MLlib with Python and make recommendations
[Reading Notes] Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow Chapter 1
scikit-learn How to use summary (machine learning)
Stock price forecast using machine learning (scikit-learn)
Predict power demand with machine learning Part 2
Machine learning imbalanced data sklearn with k-NN
Machine learning with python (2) Simple regression analysis
A story about machine learning with Kyasuket
Try with Chainer Deep Q Learning --Launch
Try deep learning of genomics with Kipoi
[Shakyo] Encounter with Python for machine learning
Machine learning with Pytorch on Google Colab
Build AI / machine learning environment with Python
Reinforcement learning 11 Try OpenAI acrobot with ChainerRL.
Isomap with Scikit-learn
Clustering with scikit-learn (1)
Clustering with scikit-learn (2)
PCA with Scikit-learn
[Memo] Machine learning
Machine learning classification
kmeans ++ with scikit-learn
[Memo / Creating] "Hands-On Machine Learning with Scikit-Learn & TensorFlow" English translation into Japanese
Machine Learning sample
Machine learning starting with Python Personal memorandum Part2
Try to forecast power demand by machine learning
Machine learning starting with Python Personal memorandum Part1
[Python] Collect images with Icrawler for machine learning [1000 images]
Machine learning starting from scratch (machine learning learned with Kaggle)
Looking back on learning with Azure Machine Learning Studio
Overview of machine learning techniques learned from scikit-learn