LoslegenKostenlos loslegen

Model matrix for continuous variables

In the video you learned about the model formula, the under-the-hood workings of the dmatrix() to obtain the model matrix and how it relates to the glm() function. As you have learned the input to dmatrix() is the right hand side of the glm() formula argument. In case the variables are part of the dataframe, then you should also specify the data source via the data argument.

dmatrix('y ~ x1 + x2', 
        data = my_data)

In this exercise you will analyze and confirm the structure of your model before model fit.

The dataset wells has been preloaded in the workspace.

Diese Übung ist Teil des Kurses

Generalized Linear Models in Python

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import function dmatrix()
from ____ import ____

# Construct model matrix with arsenic
model_matrix = ____('____', data = ____, return_type = 'dataframe')
print(model_matrix.____())
Code bearbeiten und ausführen