UCI DATA SETS
OBJECTIVE: To apply and explore various plotting functions on UCI data sets. a. Normal curv
es b. Density and contour plots c. Correlation and scatter plots d. Histograms 60 e. Three dimensi
onal plotting
from mpl_toolkits.mplot3d import Axes3D
from [Link] import StandardScaler
import numpy as np
import pandas as pd
import seaborn as sns
import [Link] as plt
import scipy
from [Link] import norm
%matplotlib inline
path="/[Link]"
df=pd.read_csv(path)
[Link](3)
[Link](x='Species',data=df)
<Axes: xlabel='Species', ylabel='count'>
[Link](x='Species',data=df)
<Axes: xlabel='Species', ylabel='count'>
axis = [Link]()
[Link]([Link], [Link])
[Link](xlabel='Sepal_Length (cm)',
ylabel='Sepal_Width (cm)',
title='Sepal-Length vs Width');
[Link](figsize=(8,4))
[Link](x='Species',y='SepalWidthCm',data=df ,palette='YlGnBu')
<ipython-input-18-c9f366b23bbc>:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed i
n v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the sa
me effect.
[Link](x='Species',y='SepalWidthCm',data=df ,palette='YlGnBu')
<Axes: xlabel='Species', ylabel='SepalWidthCm'>
[Link](df, hue='Species')
<[Link] at 0x7b0c84bfe3b0>
axis = [Link](bins=30, alpha=0.5)
axis.set_xlabel('Size in cm');
[Link](x='SepalLengthCm', y='SepalWidthCm', hue='Species', data=df)
[Link]()
numerical_cols = ['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWid
thCm']
for col in numerical_cols:
mu, std = [Link](df[col])
x = [Link](df[col].min(), df[col].max(), 100)
pdf = [Link](x, mu, std)
[Link](df[col], bins=20, density=True, alpha=0.6, label='Data')
[Link](x, pdf, 'r-', label='Normal Fit')
[Link](f'Normal Curve Fit for {col}')
[Link](col)
[Link]('Probability Density')
[Link]()
[Link]()
[Link](x='SepalLengthCm', y='SepalWidthCm', data=df, kind='kde')
[Link]()
[Link](x='SepalLengthCm', y='SepalWidthCm', data=df, kind='kde', fill=
True)
[Link]()
[Link](x='SepalLengthCm', y='SepalWidthCm', data=df, kind='kde', fill=
True, cmap='viridis')
[Link]()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-051720a24e03> in <cell line: 1>()
----> 1 [Link](x='SepalLengthCm', y='SepalWidthCm', data=df, kind='kde
')
2 [Link]()
3 [Link](x='SepalLengthCm', y='SepalWidthCm', data=df, kind='kde
', fill=True)
4 [Link]()
5 [Link](x='SepalLengthCm', y='SepalWidthCm', data=df, kind='kde
', fill=True, cmap='viridis')
NameError: name 'sns' is not defined
fig = [Link](figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
x = df['SepalLengthCm']
y = df['SepalWidthCm']
z = df['PetalLengthCm']
ax.plot_wireframe([Link]([x, x]).reshape(2, -1), [Link]([y, y]).reshape(2
, -1), [Link]([z, z]).reshape(2, -1))
ax.set_xlabel('Sepal Length (cm)')
ax.set_ylabel('Sepal Width (cm)')
ax.set_zlabel('Petal Length (cm)')
ax.set_title('3D Wireframe Plot of Iris Data')
[Link]()
fig = [Link](figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
x = df['SepalLengthCm']
y = df['SepalWidthCm']
z = df['PetalLengthCm']
colors = df['Species'].map({'Iris-setosa': 'r', 'Iris-versicolor': 'g', 'Iris
-virginica': 'b'})
ax.plot_trisurf(x, y, z, cmap='viridis', edgecolor='none')
ax.set_xlabel('Sepal Length (cm)')
ax.set_ylabel('Sepal Width (cm)')
ax.set_zlabel('Petal Length (cm)')
ax.set_title('3D Trisurf Plot of Iris Data')
[Link]()
INFERENCE: Various plotting functions were successfully applied and explored on the UCI
data sets, including normal curves, density and contour plots, correlation and scatter plots,
histograms, and three-dimensional plots.