線形関係の可視化

Pythonで学ぶ線形モデリング入門

Jason Vestuto

Data Scientist

クイックプロット

import matplotlib.pyplot as plt
plt.plot(x, y, 'r-o')
plt.show()

Pythonで学ぶ線形モデリング入門

オブジェクトインターフェース

# Import the pyplot module
import matplotlib.pyplot as plt
# Create figure and axis objects
fig, axis = plt.subplots()
# Prepare initial style options
options = dict(marker='o', color='blue')
Pythonで学ぶ線形モデリング入門

オブジェクトインターフェース

# Call the plot method on the axis object
line = axis.plot(x, y, **options)
# Modify the axis object with set methods
_ = axis.set_ylabel('Times')
_ = axis.set_xlabel('Distances')
# Display figure
plt.show()
Pythonで学ぶ線形モデリング入門

線形データの可視化

  • 2点:
    • (x1,y1) = (0,0)
    • (x2,y2) = (2,3)
  • xとyの変化量:
    • dy = (y2 - y1) = 3 - 0
    • dx = (x2 - x1) = 2 - 0
  • 傾き = 縦の変化 / 横の変化
    • slope = dy/dx = 3/2
  • 切片:
    • x=0 のとき: y1 = 0

縦の変化と横の変化による傾きを示したグラフ

Pythonで学ぶ線形モデリング入門

練習しましょう!

Pythonで学ぶ線形モデリング入門

Preparing Video For Download...