Scikit_Learn紹介と攻略

免責事項:この記事はブロガーオリジナル記事です、続くBY-SAのCC 4.0を著作権契約、複製、元のソースのリンクと、この文を添付してください。
このリンク: https://blog.csdn.net/xiewenrui1996/article/details/101034742

、scikit-学ぶプロフィール

scikit学習は機械学習のために構築されたscipyのダウンロードPythonモジュールに基づいています。様々な応用分野では、我々は、彼らが、まとめScikitsとして知られ、scipyのダウンロードパッケージに基づいて、ツールの多数を高めています。すべてのブランチのバージョンでは、scikit-学ぶ最も有名なのは、オープンソースでされ、誰でも無償または二次開発のためのライブラリを使用することができます。sklearnあなたもダウン直接ダウンロードする直接Quguanネットワークモデルを見ることができ、多くのモデルはすでに良い仕事をするがあります。

scikit-学ぶ多くのトップ機械学習アルゴリズムを含み、6つの基本的な機能、すなわち、分類、回帰、クラスタリング、データ削減、モデル選択とデータの前処理があります。scikit-学ぶ非常にアクティブなユーザーコミュニティがあり、基本的にすべてのその機能のは、ユーザーが確認するために非常に詳細なドキュメントです。scikit学習ユーザーガイドやマニュアルを参照して読むことができ、その使用アルゴリズムは、より完全に理解します。

第二に、ライブラリーは、学習scikit導入しました

%matplotlib inline
import numpy as np
import scipy
import sklearn  #导入scikit—learn库

多くのデータ・セットが使用するコードの選択に続いて、ダウンロードすることができscikit-学びます

%matplotlib inline
import numpy as np
import scipy
import sklearn


from sklearn.datasets import load_iris  #花的分类
iris=load_iris()
n_samples,n_datas=iris.data.shape
print(n_samples,n_datas)
print(iris.target_names)

##输出 150 4
['setosa' 'versicolor' 'virginica']

import matplotlib.pyplot as plt
x_index=1   #第二列
y_index=2
plt.scatter(iris.data[:,x_index],iris.data[:,y_index],c=iris.target)
plt.xlabel(iris.feature_names[x_index])
plt.ylabel(iris.feature_names[y_index])

出力画像は次のとおりです。

from sklearn.datasets import load_digits
digits=load_digits()
#这个是手写数字的训练集,标签为1~9

第三に、モデルインスタンス、モデル選択

 

モデルの一般的なインポートライブラリ:

from sklearn.linear_model import LinearRegression
from sklearn.tree import DecisionTreeRegressor

一般的な手順は、最初のオブジェクトを作成し、(ケース)にフィットし、その後)(予測を予測し、最終的にプログラムに記載されている)(写真にプロット散乱を散乱することです

import numpy as np
import matplotlib.pyplot as plt
import sklearn
from sklearn.linear_model import LinearRegression
clf=LinearRegression()
from sklearn.datasets import load_boston
data=load_boston()

n_samples,n_features=data.data.shape
print(n_samples,n_features)
print(data.target.shape)
column_i=5
plt.scatter(data.data[:,column_i],data.target)
print(data.feature_names[5])
from sklearn.metrics import mean_absolute_error
clf.fit(data.data,data.target)
predicted=clf.predict(data.data)
mean_absolute_error(data.target,predicted)
plt.scatter(data.target,predicted)
plt.xlabel("ture prices")
plt.ylabel('predicted prices')
plt.plot(data.target,predicted,color='red')

出力:

モデル選択

おすすめ

転載: blog.csdn.net/xiewenrui1996/article/details/101034742