Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.22 KB

H6.md

File metadata and controls

45 lines (33 loc) · 1.22 KB

H6 -> 2 kwantitatieve variabelen

Visualisatie

# scatterplot
sns.relplot(data=penguins,
            x='flipper_length_mm', y='body_mass_g',
            hue='species', style='sex')

regressie

from sklearn.linear_model import LinearRegression

x = data.x.values.reshape(-1,1)
y = data['y']

model = LinearRegression().fit(x, y)

print(f"Regression line: ŷ = {model.intercept_:.2f} + {model.coef_[0]:.2f} x")

# Predict y values corresponding to x
model.predict([[valueOpX]])[0]

covariantie + R + R^2

correlation coefficient and the coefficient of determination.

$abs(R)$ $R^2$ Explained variance Linear relation
< .3 < .1 < 10% very weak
.3 - .5 .1 - .25 10% - 25% weak
.5 - .7 .25 - .5 25% - 50% moderate
.7 - .85 .5 - .75 50% - 75% strong
.85 - .95 .75 - .9 75% - 90% very strong
> .95 > .9 > 90% exceptionally strong
cor = np.corrcoef(cats.Hwt, cats.Bwt)[0][1]
print(f"R = { cor }")
print(f"R² = {cor ** 2}")