Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
10 views
5 pages
B Question5
Uploaded by
linux lover
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save B_Question5 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
10 views
5 pages
B Question5
Uploaded by
linux lover
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save B_Question5 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save B_Question5 For Later
You are on page 1
/ 5
Search
Fullscreen
Question 5 IRIS ?ython for Data Science - Perform Data Visualization on Iris Dataset a)Load the Titanic dataset into one of the data structures (NumPy or Fandas). )Display header rows and description of the loaded dataset. ©) Clean the data if applicable d) Find the average petal width of each category of IRIS Species @) Data Visualization for: (i) How many flowers of each species exists for each value of sepal width (i) How many flowers are there whose petal width is <1, between 1 to 2 and >2 (i) Tally the Iris-Versicolour and Iris-Virginica species according to the value of Sepal Width Click here to download dataset fnumpy - Deals multi-dimensional arrays and matrices aseaborn - Deals with data visualization ‘matplotlib - Plotting; pyplot-interactive plotting pandas - data structures and data analysis tools import seaborn as sns import pandas as pd import matplotiib.pyplot as plot a#Import csv file into variable (dataframe) Aris df = pd.read_csv(‘iris.csv') iris df.head() Sepal_Length Sepal Width Petal_Length Petal Width Class 0 35 14 02 Iris-setosa 1 49 30 14 012 Iris-setosa 2 47 32 13 0.2 ris-setosa 3 46 34 15 012 ris-setosa 4 5c 36 14 0.2 Iris-setosa print info about datafrane print("This is info() output\n") print (inis_df.info()) print("\nthis is describe() output\n") print (iris_df.describe())This is info() output
RangeIndex: 150 entries, @ to 148 bata columns (total § columns) Non-Nul1 Count Dtype # Column 2 Sepal_tength 1 Sepal_width 2 Petal_tength 3 Petal_width 4 Class 150 150 150 150 150 non-null non-null non-null non-null non-null dtypes: floate4(4), object(1) memory usag None 6.0+ KB This is describer() output Sepal_Length count 150. mean std min 25% 50%, 75% max drop sepal_U Anis_d#.drop(['Sepal_Length’ ), axis=1, inplace=True) inis_d*.head( 200000 843333 828066 - 300800 108000 800000 408600 902800 ‘ength ) se u spal_Width 50.600000 054000, 433594 208000 800000 208000 308000 408000 PeuNvew Floated Floate4 floated Floated object Petal_Length 150.000000 758667 764426 00000 600000 350000 100008 -980008 One EEY Sepal Width Petal Length Petal Width Class ° 35 1 30 2 32 3 3, 4 36 14 14 13 15 14 02 tis-setosa 02. tis-setosa 02. tis-setosa 02. tis-setosa 02. tis-setosa Petal_width 150 200000 -198667 -763161 100000 -308000 300008 800000 500000 inis_df.groupby( ‘Class’ ,as_index=False)[' Petal_Width" ].mean() Class 0 ris-setose 1 ris-versicolor 2 ris-virginice Petal Width 9244 1326 2.026 # we increase the size of output graph plot. Figure(figsize=[12,6])
‘plot graph of class vs sepalwidth ax=sns.countplot (data=iris_df,x=" Sepal_width’ hue= "Class", palette="Set1") ax.set(title='Flower of each species’ ,xlabel="Sepal Width" ,ylabel='No. of flowers") plot.tight_layout() plot .show() Flower of each species lass mm ris-setosa lm Iris-versicolor mE Iris-virginica No. of flowers 2.0 2.22.3 2.42.5 2.6 2.72.8 2.93.0 3.13.2 333.435 3.63.73.83.9404.14244 Sepal Width Cut petal width accoding to interval and give Labels from categories interval = (0,1,2,4) category = ["<1','1 to 2","22'] Anis_df['Petal_catg') = pd.cut(iris_df[' Petal_Width' ), interval, labels=category) ax = sns.countplot(data = iris df,x = 'Petal_catg' ,hue='Class' ,palette='seti') ax.set(title='Petal Width’, xlabel='Category of Petals’ ,ylabel='No. of flowers") plot.show()Petal Width 50 Class lm Iris-setosa lm ris-versicolor 0 mE Iris-virginica % 30 & 2 2 20 10 o <1 ax = sns.countplot (data 1to2 Category of Petals iris_df[iris_df[ ‘Class’ >2 "Inis-setosa’],x = * Sepal_widt ax.set(title='Versicolor vs virginica’ ,xlabel="Sepal Width’ ,ylabel='No. of flowers’ plot.show()No. of flowers 2 10 © a Versicolor vs virginica Class lm iris-versicolor Mm ris-virginica 20 22 2.3 2.4 25 26 27 2829 3031 32 33 34 36 38 Sepal Width
You might also like
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (643)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4.5/5 (1856)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4.5/5 (4103)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1175)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2289)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4.5/5 (1139)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (836)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (233)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (144)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M.L. Stedman
4.5/5 (815)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (629)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (943)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (298)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (903)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (2885)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (919)
Little Women
From Everand
Little Women
Louisa May Alcott
4.5/5 (2369)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1267)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (244)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2546)