Aan de slagGa gratis aan de slag

Manually calculating predictions with interactions

In order to understand how .predict() works, it's time to calculate the predictions manually again. For this model, there are three separate lines to calculate for, and in each one, the prediction is an intercept plus a slope times the numeric explanatory value. The tricky part is getting the right intercept and the right slope for each case.

mdl_price_vs_both_inter and explanatory_data are available.

Deze oefening maakt deel uit van de cursus

Intermediate Regression with statsmodels in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Get the coefficients from mdl_price_vs_both_inter
coeffs = ____

# Assign each of the elements of coeffs
____
Code bewerken en uitvoeren