BaşlayınÜcretsiz başlayın

Variable transformation

Continuing with the wells you will practice applying variable transformation directly in the formula and model matrix setting without the need to add the transformed data to the data frame first. You will also revisit the computation of model error or deviance to see if the transformation improved the model fit.

Recall the structure of dmatrix() function is the right hand side of the glm() formula argument in addition to the data argument.

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

The dataset wells and the model model_ars with arsenic (original variable) have been preloaded in the workspace.

Bu egzersiz, kursun bir parçasıdır

Generalized Linear Models in Python

Kursa Göz Atın

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Import function dmatrix
import ____ as ____
from ____ import ____

# Construct model matrix for arsenic with log transformation
____('np.____(____)', data = ____,
       return_type = 'dataframe').head()
Kodu Düzenle ve Çalıştır