Predicting if students will pass
In the previous exercise you calculated the parameters of the logistic regression model that fits the data of hours of study and test outcomes.
With those parameters you can predict the performance of students based on their hours of study. Use model.predict()
to get the outcomes based on the logistic regression.
For your convenience, LogisticRegression
has been imported from sklearn.linear_model
and numpy
has been imported as np
.
This exercise is part of the course
Foundations of Probability in Python
Exercise instructions
- Create an array with the values 10, 11, 12, 13, and 14 to predict the outcomes for a test based on those numbers of hours of study.
- Use
model.predict()
to get the outcomes from the model, and print the outcomes. - Use
model.predict_proba()
to get the probability of passing the test with 11 hours of study.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Specify values to predict
hours_of_study_test = [[____], [____], [____], [____], [____]]
# Pass values to predict
predicted_outcomes = model.____(____)
print(predicted_outcomes)
# Set value in array
value = np.asarray(11).reshape(-1,1)
# Probability of passing the test with 11 hours of study
print("Probability of passing test ", model.____(value)[:,1])