0% found this document useful (0 votes)
7 views4 pages

Dsbda La 10

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Dsbda La 10

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

# Libraries import.

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Get the url and columns of the csv file.


url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
columns = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species']

# Load csv file.


iris = pd.read_csv(url, header=None, names=columns)
iris

sepal_length sepal_width petal_length petal_width species

0 5.1 3.5 1.4 0.2 Iris-setosa

1 4.9 3.0 1.4 0.2 Iris-setosa

2 4.7 3.2 1.3 0.2 Iris-setosa

3 4.6 3.1 1.5 0.2 Iris-setosa

4 5.0 3.6 1.4 0.2 Iris-setosa

... ... ... ... ... ...

145 6.7 3.0 5.2 2.3 Iris-virginica

146 6.3 2.5 5.0 1.9 Iris-virginica

147 6.5 3.0 5.2 2.0 Iris-virginica

148 6.2 3.4 5.4 2.3 Iris-virginica

149 5.9 3.0 5.1 1.8 Iris-virginica

150 rows × 5 columns

# Features and data types.


print("Features and their types: ")
iris.dtypes

Features and their types:


0

sepal_length float64

sepal_width float64

petal_length float64

petal_width float64

species object

dtype: object

# Histogram
cols = iris.drop('species', axis=1)
cols.hist(bins=15, figsize=(10, 7))
array([[<Axes: title={'center': 'sepal_length'}>,
<Axes: title={'center': 'sepal_width'}>],
[<Axes: title={'center': 'petal_length'}>,
<Axes: title={'center': 'petal_width'}>]], dtype=object)

# Boxplot.
plt.figure(figsize=(10, 7))
sns.boxplot(cols)
plt.title("Box Plot of Features", fontsize=16)
plt.show()

# Comparing the distributions and identify outliers.


plt.figure(figsize=(10, 7))
sns.boxplot(x="species", y="sepal_length", data=iris)
plt.title("Box Plot of Sepal Length Vs Species", fontsize=16)
plt.show()
plt.figure(figsize=(10, 7))
sns.boxplot(x="species", y="sepal_width", data=iris)
plt.title("Box Plot: Petal Length Vs Species", fontsize=16)
plt.show()

plt.figure(figsize=(10, 7))
sns.boxplot(x="species", y="petal_length", data=iris)
plt.title("Box Plot: Petal Longth Vs Species", fontsize=16)
plt.show()
plt.figure(figsize=(10, 7))
sns.boxplot(x="species", y="petal_width", data=iris)
plt.title("Box Plot: Petal Width Vs Species", fontsize=16)
plt.show()

Start coding or generate with AI.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy