LoslegenKostenlos loslegen

Linear model, a special case of GLM

In this exercise you will fit a linear model two ways, one using the ols() function and one using the glm() function. This will show how a linear model is a special case of a generalized linear model (GLM).

You will use the preloaded salary dataset introduced in the video.

Recall that the linear model in Python is defined as:

ols(formula = 'y ~ X', data = my_data).fit()

and the generalized linear model can be trained using

glm(formula = 'y ~ X', data = my_data, family = sm.families.___).fit()

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 ____ as ____
from ____.____.____ import ____, ____

# Fit a linear model
model_lm = ols(formula = '____ ~ ____',
               data = ____).fit()

# View model coefficients
print(model_lm.params)
Code bearbeiten und ausführen