Foundations of Probability 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} $$
What would be the criteria to determine which is the best model?
# Import LinearRegression
from sklearn.linear_model import LinearRegression
# sklearn linear model
model = LinearRegression()
model.fit(hours_of_study, scores)
# Get parameters
slope = model.coef_[0]
intercept = model.intercept_
# Print parameters
print(slope, intercept)
(1.496703900384545, 52.44845266434719)
# Score prediction
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()
Foundations of Probability in Python