Aan de slagGa gratis aan de slag

Fitting a logistic model

The university studying the relationship between hours of study and outcomes on a given test has provided you with a dataset containing the number of hours the students studied and whether they failed or passed the test, and asked you to fit a model to predict future performance.

The data is provided in the variables hours_of_study and outcomes. Use this data to fit a LogisticRegression model. numpy has been imported as np for your convenience.

Deze oefening maakt deel uit van de cursus

Foundations of Probability in Python

Cursus bekijken

Oefeninstructies

  • Import LogisticRegression from sklearn.linear_model.
  • Create the model using LogisticRegression(C=1e9).
  • Pass the data to the model.fit() method.
  • Create variables for each parameter, assign the values from the model, and print the parameters beta1 and beta0.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import LogisticRegression
from sklearn.linear_model import ____

# sklearn logistic model
model = ____(C=1e9)
model.____(____, ____)

# Get parameters
beta1 = model.coef_[0][0]
beta0 = model.intercept_[0]

# Print parameters
print(____, ____)
Code bewerken en uitvoeren