Now that you know all about logistic regression, let's implement it in Python using the scikit-learn library. Let's create a model using naive Bayes classification. We will do so using the following steps:
- We will first import the dataset and the required libraries using the following code:
# Import libraries import pandas as pd
# read the dataset diabetes = pd.read_csv("diabetes.csv")
# Show top 5-records diabetes.head()
This results in the following output:
In our preceding example, we are reading the Pima Indians Diabetes dataset. This dataset does not give the column names, so we have to do so.
- In the read_csv() function, we will pass the header to None and names to the column list that was created before reading the CSV file:
# Split dataset in two parts: feature set and target label feature_set = ['pregnant', 'insulin', 'bmi', 'age','glucose','bp&apos...