Sunday, March 15, 2020

Iris dataset using Decision Trre==

Hello All,

Today in this blog I am going to explain you how to solve a Supervised learning problem by considering a multi-class classification problem using a Iris dataset.

I have considered Iris dataset so that a beginner in a datascience field can easily understand the concept behind a Supervised Learning problem.

About "Iris data" in short: It has 4 features - 'Sepal length", "Sepal Width', 'Petal length' and 'Petal width' based on which we need to classify whether the output ('iris') goes into which of the three categories ('Setosa' or 'Versicolor' or 'Virginica')

Steps to follow:

Step:1 Import required Libraries
         
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
Step:2 Load the csv file on which we need to work

dataset=pd.read_csv(r'C:\......\iris.csv')
Step: 3

dataset.head()

sepal lengthsepal widthpetal lengthpetal widthiris
05.13.51.40.2Iris-setosa
14.93.01.40.2Iris-setosa
24.73.21.30.2Iris-setosa
34.63.11.50.2Iris-setosa
45.03.61.40.2Iris-setosa


dataset.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 150 entries, 0 to 149
Data columns (total 5 columns):
sepal length    150 non-null float64
sepal width     150 non-null float64
petal length    150 non-null float64
petal width     150 non-null float64
iris            150 non-null object
dtypes: float64(4), object(1)
memory usage: 5.9+ K