始める無料で始める

モデリングを行う理由: 補間

モデリングの一般的な用途の1つは、測定データ点の「内側」や「間」にある値を求めるための補間です。この演習では、独立変数 times がロードトリップの2つの計測の「間」にあるとき、従属変数 distances の値を予測します。ここで distances は、与えられた経過時間に対して移動した距離です。

context figure

この演習はコースの一部です

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

コースを見る

演習の手順

  • あらかじめ定義された配列 timesdistances、および読み込まれているプロットを確認します。
  • おおまかな見た目の確認に基づいて、elapse_time = 2.5 時点で出発地点からどれだけ離れているか(distance_traveled)を見積もります(単位は時間)。
  • 見積もった値を distance_traveled に代入します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# Compute the total change in distance and change in time
total_distance = ____[-1] - ____[0]
total_time = ____[-1] - ____[0]

# Estimate the slope of the data from the ratio of the changes
average_speed = total_distance / total_time

# Predict the distance traveled for a time not measured
elapse_time = 2.5
distance_traveled = average_speed * elapse_time
print("The distance traveled is {}".format(distance_traveled))
コードを編集して実行