Basis van kansrekening in Python
Alexander A. Ramírez M.
CEO @ Synergy Vision


$$ y = \color{red}{slope}*x + \color{blue}{intercept} $$

$$ y = slope*x + intercept + \color{red}{random\_number} $$


Wat is het criterium om te bepalen welk model het beste is?




# Import LinearRegression
from sklearn.linear_model import LinearRegression
# sklearn lineair model
model = LinearRegression()
model.fit(hours_of_study, scores)
# Parameters ophalen
slope = model.coef_[0]
intercept = model.intercept_
# Parameters printen
print(slope, intercept)
(1.496703900384545, 52.44845266434719)
# Score voorspellen
score = model.predict(np.array([[15]]))
print(score)
[74.89901117]
$$ $$
import matplotlib.pyplot as plt
plt.scatter(hours_of_study, scores)
plt.plot(hours_of_study_values, model.predict(hours_of_study_values))
plt.show()

Basis van kansrekening in Python