By which method can logistic regression be implemented?

A logistic regression model can be created by importing scikit-learn's LogisticRegression method. We load the packages as we did previously for creating a linear regression model:

import pandas as pdimport numpy as npfrom sklearn import preprocessingimport matplotlib.pyplot as pltfrom sklearn.linear_model import LogisticRegression

We will use the dataset of an HR department that has the list of employees who have attrited in the past along with the employees who are continuing in the job:

hr_data = pd.read_csv('data/hr.csv', header=0)hr_data.head()hr_data = hr_data.dropna()print(hr_data.shape)print(list(hr_data.columns))

The output of the preceding code is as follows:

The dataset has ...

Get Hands-On Automated Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.