Monday, 3 October 2022

6 c. Apply and explore histograms and three dimensional plotting functions on UCI data sets

 6 c. Apply and explore histograms and three dimensional plotting functions on UCI data sets 

Aim

          To apply and explore histograms and three dimensional plotting functions on UCI data sets 

Procedure

ü Download CSV file and upload to explore.

ü  A histogram is basically used to represent data provided in a form of some groups.

ü  To create a histogram the first step is to create bin of the ranges, then distribute the whole range of the values into a series of intervals, and count the values which fall into each of the intervals.

ü Bins are clearly identified as consecutive, non-overlapping intervals of variables.The matplotlib.pyplot.hist() function is used to compute and create histogram of x. 

ü The first one is a standard import statement for plotting using matplotlib, which you would see for 2D plotting as well.

ü The second import of the Axes3D class is required for enabling 3D projections. It is, otherwise, not used anywhere else.

 

Program

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt  # To visualize

from mpl_toolkits.mplot3d import Axes3D

data = pd.read_csv('d:\\diabetes.csv')

data

data['Glucose'].plot(kind='hist')

Output

fig = plt.figure(figsize=(4,4))

ax = fig.add_subplot(111, projection='3d')

Output

fig = plt.figure()

ax = fig.add_subplot(111, projection='3d')

x = data['Age'].values

y = data['Glucose'].values

z = data['Outcome'].values

ax.set_xlabel("Age (Year)")

ax.set_ylabel("Glucose (Reading)")

ax.set_zlabel("Outcome (0 or 1)")

ax.scatter(x, y, z, c='r', marker='o')

plt.show()

Output

 

 

 

Result

The histograms and three dimensional plotting functions on UCI data sets  are successfully executed.

No comments:

Post a Comment

CCS 365 Software Defined Network Lab Manual

 CCS 365 Software Defined Network Lab Manual 1) Setup your own virtual SDN lab i) Virtualbox/Mininet Environment for SDN - http://mininet.or...