Intermediate Regression with statsmodels in Python
Maarten Van den Broeck
Content Developer at DataCamp
Coefficient of determination (R-squared): how well the linear regression line fits the observed values.
Residual standard error (RSE): the typical size of the residuals.
print(mdl_mass_vs_length.rsquared)
0.8225689502644215
print(mdl_mass_vs_species.rsquared)
0.25814887709499157
print(mdl_mass_vs_both.rsquared)
0.9200433561156649
statsmodels, it's contained in the rsquared_adj attribute.print("rsq_length: ", mdl_mass_vs_length.rsquared)
print("rsq_adj_length: ", mdl_mass_vs_length.rsquared_adj)
rsq_length:  0.8225689502644215
rsq_adj_length:  0.8211607673300121
print("rsq_species: ", mdl_mass_vs_species.rsquared)
print("rsq_adj_species: ", mdl_mass_vs_species.rsquared_adj)
rsq_species:  0.25814887709499157
rsq_adj_species:  0.24020086605696722
print("rsq_both: ", mdl_mass_vs_both.rsquared
print("rsq_adj_both: ", mdl_mass_vs_both.rsquared_adj)
rsq_both:  0.9200433561156649
rsq_adj_both:  0.9174431400543857
rse_length = np.sqrt(mdl_mass_vs_length.mse_resid)
print("rse_length: ", rse_length)
rse_length:  152.12092835414788
rse_species = np.sqrt(mdl_mass_vs_species.mse_resid)
print("rse_species: ", rse_species)
rse_species:  313.5501156682592
rse_both = np.sqrt(mdl_mass_vs_both.mse_resid)
print("rse_both: ", rse_both)
rse_both:  103.35563303966488
Intermediate Regression with statsmodels in Python