Plotting data and linear model fit
In the previous exercises you have practiced how to fit and interpret the Poisson regression model. In this exercise you will visually analyze the crab data and then the model fit.
First, you will plot a linear fit to the data, which later on you will use to compare to Poisson regression fitted values.
Diese Übung ist Teil des Kurses
Generalized Linear Models in Python
Anleitung zur Übung
- Import
seabornandmatplotliblibraries. - Using
crabdataset plot the data points withwidthon the x-axis andsaton the y-axis, with jitter of0.3for thesatvariable. - Add a linear model fit by setting the argument
fit_regtoTrue. - Set
'color'of the line fit as'green'and the'label'as'LM fit'.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Import libraries
import ____ as sns
import ____.pyplot as plt
# Plot the data points and linear model fit
sns.regplot(____, ____, data = ____,
y_jitter = ____,
fit_reg = ____,
line_kws = {'color':____,
'label':____})
# Print plot
plt.show()