Pythonで機械学習(sckit-learn)

# 概要
sckit-learnのまとめみたいなもの書きたいなーと。

# インストール方法
```
pip install scikit-learn
```

# 手法の選択
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/88552/516daf0f-52af-05bf-0edd-dddc89249c60.png)

[公式サイト](https://scikit-learn.org/stable/tutorial/machine_learning_map/)にも記載されています。

* classification(分類) - ラベルとデータを学習し、データに対してのラベルを予測する。
* regression(回帰) - 実数値をデータで学習して、実数値を予測する。
* clustering(クラスタリング) - データの似ているもの同士をまとめて、データの構造を発見する。
* dimensionality reduction(次元削減) - データの次元を削減して、要因を発見 (主成分分析など) したり、他の手法の入力に使う (次元の呪い回避)。

ここから画像の手法名と公式でリンクされているクラスを記載します。

# 手法：classification
[![Screenshot from Gyazo](https://gyazo.com/335d9aff6bac11cb3403b29a3999de2d/raw)](https://gyazo.com/335d9aff6bac11cb3403b29a3999de2d)

| 記載名 | クラス |
|:-------|:-------|
| SGD Classifier | [sklearn.linear_model.SGDClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html) |
| kernel approximation | [sklearn.kernel_approximation.Nystroem](https://scikit-learn.org/stable/modules/generated/sklearn.kernel_approximation.Nystroem.html) |
| kernel approximation | [sklearn.kernel_approximation.RBFSampler](https://scikit-learn.org/stable/modules/generated/sklearn.kernel_approximation.RBFSampler.html) |
| kernel approximation | [sklearn.kernel_approximation.AdditiveChi2Sampler](https://scikit-learn.org/stable/modules/generated/sklearn.kernel_approximation.AdditiveChi2Sampler.html) |
| kernel approximation | [sklearn.kernel_approximation.SkewedChi2Sampler](https://scikit-learn.org/stable/modules/generated/sklearn.kernel_approximation.SkewedChi2Sampler.html) |
| Linear SVC | [sklearn.svm.LinearSVC](https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html) |
| Kneighbors Classifier | [sklearn.neighbors.KNeighborsClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html) |
| Kneighbors Classifier | [sklearn.neighbors.RadiusNeighborsClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.RadiusNeighborsClassifier.html) |
| SVC | [sklearn.svm.SVC](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html) |
| SVC | [sklearn.svm.NuSVC](https://scikit-learn.org/stable/modules/generated/sklearn.svm.NuSVC.html) |
| Ensemble Classifiers | [sklearn.ensemble.BaggingClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingClassifier.html) |
| Ensemble Classifiers | [sklearn.ensemble.RandomForestClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html) |
| Ensemble Classifiers | [sklearn.ensemble.ExtraTreesClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.ExtraTreesClassifier.html) |
| Ensemble Classifiers | [sklearn.ensemble.AdaBoostClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.AdaBoostClassifier.html) |
| Ensemble Classifiers | [sklearn.ensemble.GradientBoostingClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html) |
| Ensemble Classifiers | [sklearn.ensemble.VotingClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.VotingClassifier.html) |
| Naive Bayes | [sklearn.naive_bayes.GaussianNB](https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html) |
| Naive Bayes | [sklearn.naive_bayes.MultinomialNB](https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.MultinomialNB.html) |
| Naive Bayes | [sklearn.naive_bayes.ComplementNB](https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.ComplementNB.html) |
| Naive Bayes | [sklearn.naive_bayes.BernoulliNB](https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.BernoulliNB.html) |

# 手法：regression

[![Screenshot from Gyazo](https://gyazo.com/450bc079e81c5ec98c59b84bfef59967/raw)](https://gyazo.com/450bc079e81c5ec98c59b84bfef59967)

| 記載名 | クラス |
|:-------|:-------|
| SGD Regressor | [sklearn.linear_model.SGDRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDRegressor.html) |
| Lasso | [sklearn.linear_model.Lasso](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html) |
| Lasso | [sklearn.linear_model.MultiTaskLasso](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.MultiTaskLasso.html) |
| Elastic Net | [sklearn.linear_model.ElasticNet](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNet.html) |
| Elastic Net | [sklearn.linear_model.MultiTaskElasticNet](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.MultiTaskElasticNet.html) |
| Ridge Regression | [sklearn.linear_model.Ridge](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html) |
| SVR(kernel='linear') | [sklearn.svm.SVR](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html) |
| SVR(kernel='rbf') | [sklearn.svm.SVR](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html) |
| Ensemble Regressors | [sklearn.ensemble.BaggingRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingRegressor.html) |
| Ensemble Regressors | [sklearn.ensemble.RandomForestRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html) |
| Ensemble Regressors | [sklearn.ensemble.ExtraTreesRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.ExtraTreesRegressor.html) |
| Ensemble Regressors | [sklearn.ensemble.AdaBoostRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.AdaBoostRegressor.html) |
| Ensemble Regressors | [sklearn.ensemble.GradientBoostingRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingRegressor.html) |

# 手法：clustering

[![Screenshot from Gyazo](https://gyazo.com/cd9505a09077e178982f7cb0f697b3ad/raw)](https://gyazo.com/cd9505a09077e178982f7cb0f697b3ad)

| 記載名 | クラス |
|:-------|:-------|
| Mean Shift | [sklearn.cluster.MeanShift](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.MeanShift.html) |
| VBGMM | [sklearn.mixture.BayesianGaussianMixture](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html) |
| MiniBatch KMeans | [sklearn.cluster.MiniBatchKMeans](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.MiniBatchKMeans.html) |
| Kmeans | [sklearn.cluster.Kmeans](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html) |
| Spectral Clustering | [sklearn.cluster.SpectralClustering](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.SpectralClustering.html) |
| GMM | [sklearn.mixture.GaussianMixture](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html) |

# 手法：dimensionality reduction

[![Screenshot from Gyazo](https://gyazo.com/7a5a0918358a3f018b11d00ea86a6d92/raw)](https://gyazo.com/7a5a0918358a3f018b11d00ea86a6d92)

| 記載名 | クラス |
|:-------|:-------|
| Randomized PCA | [sklearn.decomposition.PCA](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html) |
| Randomized PCA | [sklearn.decomposition.IncrementalPCA](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.IncrementalPCA.html) |
| Randomized PCA | [sklearn.decomposition.KernelPCA](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.KernelPCA.html) |
| Randomized PCA | [sklearn.decomposition.SparsePCA](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.SparsePCA.html) |
| Randomized PCA | [sklearn.decomposition.MiniBatchSparsePCA](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.MiniBatchSparsePCA.html) |
| Isomap | [sklearn.manifold.Isomap](https://scikit-learn.org/stable/modules/generated/sklearn.manifold.Isomap.html) |
| Spectral Embedding | [sklearn.manifold.SpectralEmbedding](https://scikit-learn.org/stable/modules/generated/sklearn.manifold.SpectralEmbedding.html) |
| LLE | [sklearn.manifold.LocallyLinearEmbedding](https://scikit-learn.org/stable/modules/generated/sklearn.manifold.LocallyLinearEmbedding.html) |

# 参考

https://qiita.com/ynakayama/items/9c5867b6947aa41e9229

# 終わりに

* [公式サイトの画像](https://scikit-learn.org/stable/tutorial/machine_learning_map/)でのリンク先で記載されているものをまとめたものです。
* 各手法の詳細は自身で調査してください
* 誤字・脱字、記載漏れはご了承ください