Fitting a model
A university has provided you with data that shows a relationship between the hours of study and the scores that the students get on a given test.
You have access to the data through the variables hours_of_study
and scores
. Use a linear model to learn from the data.
Diese Übung ist Teil des Kurses
Foundations of Probability in Python
Anleitung zur Übung
- Import the
linregress()
function fromscipy.stats
. - Fit a linear model using the provided data in the
hours_of_study
andscores
variables. - Print the parameters.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Import the linregress() function
from scipy.stats import ____
# Get the model parameters
slope, intercept, r_value, p_value, std_err = ____(____, ____)
# Print the linear model parameters
print('slope:', ____)
print('intercept:', ____)