始める無料で始める

解釈しやすい係数による交互作用

前回の交互作用項を含むモデルでは、解釈がやや難しい係数が得られました。モデルが何を予測しているのかをより明確にするために、理解しやすい係数が得られるようにモデルを再構成できます。さらに明確にするため、住宅の築年数カテゴリ別の個別モデル(mdl_0_to_15、mdl_15_to_30、mdl_30_to_45)の結果と比較してみましょう。

taiwan_real_estate、mdl_0_to_15、mdl_15_to_30、mdl_30_to_45 が使用できます。

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

statsmodels を使った中級 Regression

コースを見る

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

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

# Model price vs. house age plus an interaction, no intercept
mdl_readable_inter = ____

# Print the coefficients for mdl_0_to_15
print("mdl_0_to_15 coefficients:", "\n", ____)

# Print the coefficients for mdl_15_to_30
print("mdl_15_to_30 coefficients:", "\n", ____)

# Print the coefficients for mdl_30_to_45
print("mdl_30_to_45 coefficients:", "\n", ____)

# Print the coefficients for mdl_readable_inter
print("\n", "mdl_readable_inter coefficients:", "\n", mdl_readable_inter.params)
コードを編集して実行