O'Reilly logo

Hands-On Automated Machine Learning by Umit Mert Cakmak, Sibanjan Das

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required