Saturday, November 13, 2021

Implementation of Machine Learning using Python

 # General Changes

# 1. Labeling the x-axis and y-axis

# 2. Title of the Graph

# 3. Figure Size

# 4. Annotate on the graph

# 5. Scale of the graph

# 6. Grid on the graph


import matplotlib.pyplot as plt

import numpy as np

plt.figure(figsize=(10,3))

x=np.array([10,30,45,67,90])

y=np.array([12,56,27,36,67])

for i in range(len(x)):

    plt.text(x[i],y[i],(x[i],y[i]))

for i in range(len(x)):

    plt.text(x[i],y[i],f'   ({x[i]},{y[i]})')

  


plt.plot(x,y,color='r',ls='--',lw=3,marker='*',ms=20,markeredgecolor='g')

plt.title('Height-Weight Graph',fontsize=20,fontweight='bold')

plt.xlim(-10,100)

plt.ylim(0,70)

plt.xlabel('X-axis values')

plt.ylabel('Y-axis values')

plt.grid()

plt.xticks(np.arange(-10,101,10))

plt.savefig("mylineplot.png")

plt.show()


# Take a numpy array named person and give 3 names for the same

# Take another numpy array named height and give their respective heights

# Plot a bar graph indicating the same

person = np.array([ 'Mr A', 'Mr B', 'Mr C' ])
height = np.array( [145,146,1351])
weight=np.array([45,56,47])                   
plt.bar(person,height,width=-0.4,align='edge',color='r',label='height')
plt.bar(person,weight,width=0.4,align='edge',color='g',label='weight')
plt.legend()
plt.xlabel('Person Name')
plt.ylabel ('Height in cms')
plt.show()



cities=np.array(['Mumbai', 'Bangalore','Ahemdabad','Delhi' ])

cities = np.array(['Mumbai','Bangalore','Ahmedabad','Delhi'])
population = np.array([12442373,8443675,5577940,11034555])
plt.pie(population,explode=[0,0.1,0,0],labels=cities,autopct='%.2f%%')
plt.show()



No comments:

Post a Comment

Clustering in Machine Learning

Clustering is a type of unsupervised learning in machine learning where the goal is to group a set of objects in such a way that objects in...