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を使ったデータ分析、機械学習
492
5
章 機械学習
In[1]: %matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
import numpy as np
5.13.1
KDE
の必要性:ヒストグラム
既に説明したように、密度推定器はデータセットを生成した確率分布をモデル化するアルゴリズ
ムです。
1
次元データの場合、ヒストグラムという単純な密度推定器については熟知しているはず
です。ヒストグラムは、データを個別のビンに分割し、各ビンに含まれるポイントの数を数え、直
感的な方法で結果を可視化します。
例えば、
2
つの正規分布から得られるデータを作成しましょう。
In[2]: def make_data(N, f=0.3, rseed=1):
rand = np.random.RandomSt
ate(rseed)
x = rand.randn(N)
x[int(f * N):] += 5
return x
x = make_data(1000)
標準的な個数ベースのヒストグラムは、
plt.hist()
関数を使って作成します。
normed
パラメー
タを指定することで、ビンの高さが個数を反映するのではなく、確率密度を反映する正規化ヒスト
グラムになります( 5-140)。
In[3]: hist = plt.hist(x, bins=30, normed=True)
図5-140 正規分布の組み合わせから得られたデータ
5.13 ...
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