Skip to Content
Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
book

Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

by Jake VanderPlas, 菊池 彰
May 2018
Intermediate to advanced
556 pages
13h 21m
Japanese
O'Reilly Japan, Inc.
Content preview from Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
384
5
章 機械学習
In[15]: from sklearn.preprocessing import Imputer
imp = Imputer(strategy='mean')
X2 = imp.fit_transform(X)
X2
Out[15]: array([[ 4.5, 0. , 3. ],
[ 3. , 7. , 9. ],
[ 3. , 5. , 2. ],
[ 4. , 5. , 6. ],
[ 8. , 8. , 1. ]])
2
つの欠損値が同じ列の値の平均で置き換えられていることがわかります。この補完されたデー
タは、例えば
LinearRegression
推定器に直接与えることができます。
In[16]: model = LinearRegression().fit(X2, y)
model.predict(X2)
Out[16]: array([ 13.14869292, 14.3784627 , -1.15539732, 10.96606197, -5.33782027])
5.4.6
 特徴パイプライン
ここまでの例のような複数のステップを組み合わせた作業を行う場合は、それぞれの変換を手作
業で行うのはとても面倒です。例えば、次のような処理パイプラインが必要な場合があります。
1.
平均を使って欠損値を補完する
2.
特徴を
2
次方程式に変換する
3.
線形回帰に当てはめる
この処理パイプラインを効率化するために、
scikit-learn
は次のように使用できるパイプラインオ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Jake VanderPlas, 菊池 彰
初めてのGraphQL ―Webサービスを作って学ぶ新世代API

初めてのGraphQL ―Webサービスを作って学ぶ新世代API

Eve Porcello, Alex Banks, 尾崎 沙耶, あんどうやすし

Publisher Resources

ISBN: 9784873118413Other