June 2020
Intermediate to advanced
382 pages
11h 39m
English
In this section, we will see how we can use the logistic regression algorithm for the classifiers challenge:
First, let's instantiate a logistic regression model and train it using the training data:
from sklearn.linear_model import LogisticRegressionclassifier = LogisticRegression(random_state = 0)classifier.fit(X_train, y_train)
Let's predict the values of the test data and create a confusion matrix:
y_pred = classifier.predict(X_test)cm = metrics.confusion_matrix(y_test, y_pred)cm
We get the following output upon running the preceding code:
Now, let's look at the ...