You are on page 1of 1

We will build a logistic regression on IRIS dataset:

Step 1: Import the relevant libraries and read the dataset

import numpy as np

import matplotlib as plt

from sklearn import datasets

from sklearn import metrics

from sklearn.linear_model import LogisticRegression

We have imported all the libraries. Next, we read the dataset:

dataset = datasets.load_iris()

Step 2: Understand the dataset by looking at distributions and plots

I am skipping these steps for now. You can read this article, if you want to learn exploratory analysis.

Step 3: Build a logistic regression model on the dataset and making predictions

model.fit(dataset.data, dataset.target)

expected = dataset.target

predicted = model.predict(dataset.data)

Step 4: Print confusion metrix

print(metrics.classification_report(expected, predicted))

print(metrics.confusion_matrix(expected, predicted))

You might also like