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を使ったデータ分析、機械学習
5.6
 詳細:線形回帰
393
ために線形モデルを一般化する方法について説明します。最初に標準的なモジュールをインポート
します。
In[1]: %matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
import numpy as np
5.6.1
 単回帰
最もよく知られている線形回帰(データに直線を当てはめる)から始めます。直線の当てはめは、
y
ax
b
という形のモデルであり、ここで
a
傾き
slope
)、
b
切片
intercept
)を表します。
傾きが
2
で、切片が−
5
である線の周りに散在している以下のデータを考えてみましょう(
5-42)。
In[2]: rng = np.random.RandomState(1)
x = 10 * rng.ra
nd(50)
y = 2 * x - 5 + rng.randn(50)
plt.scatter(x, y);
図5-42 線形回帰用のデータ
scikit-learn
LinearRegression
推定器を使用して、このデータに当てはめた最適な線を作成で
きます( 5-43)。
In[3]: from sklearn.linear_model import LinearRegression
model = LinearRegression(fit_intercept=True)
model.fit(x[:, np.newaxis], y) ...
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