Coders Packet

Iris flower classification in Python using Logistic Regression

By Sudipta Ghosh

The project aims to design and implement a system of pattern recognition for iris flowers. At the end of the project, I have obtained 96% accuracy as a result.

In this project, I have used-


pip install pandas     //how to install it in Jupyter notebook

import pandas as pd    // importing the Python package and proceed

It is a Python package provides us flexible, fast data structures designed with fundamental high-level building block.


import matplotlib.pyplot as plt

%matplotlib inline     //sometimes only importing matplotlib does not give us a proper result at those rare cases we use this 

                        inline function

It is a comprehensive visualization library for creating static, animated, and interactive visualization.


how we will install this package in Python -

pip install seaborn

##how to import it in a notebook:

import seaborn as sns


so another data visualization library that is used in this project is seaborn based on matplotlib which provides us a high-level interface for drawing an attractive statistical graph. It uses less syntax to visualize random distribution. 


So before knowing about train_test_split we will first know what sklearn (Scikit-learn). It provides us various features that can be used in classification, regression, and clustering problems.Model_selection, a method of setting a blueprint to measure the new data after analyzing the previous data. So to do that we have to train our model first, then we will test the model against another newly created model.

how to import sklearn.model_selection:

from sklearn.model_selection import train_test_split


train_test_split is a function for splitting the data into two subsets: train data, test data. this function has several parameters like X,y, train_size, test_size,random_state.



y=traget variable ; x=predictable variable 

train_size=sets the size of the training data (range from 0.1-1.0) ; test_size=sets the size of testing data(range 0.25 if training size i default)

random_state=default mode performs a random split using np. random. we can add an exact integer here like random_state=10



so sklearn.linear_model is the most commonly known package in Python. applying this package we can implement a linear regression model also a logistic regression model. For our project here we use sklearn.linear_model to go with logistic regression.

from sklearn.linear_model import LogisticRegression



Download project

Reviews Report

Submitted by Sudipta Ghosh (Sudipta)

Download packets of source code on Coders Packet