Answer to Question #299974 in Python for suresh

Question #299974

- Load iris data from load_iris function from sklearn.datasets package.

- From the dataset extract the data property.

- Train an AgglomerativeClustring model based on the data.

- Plot dendrogram to visualize the clustering linkage


1
Expert's answer
2022-02-19T16:56:22-0500
import numpy as np
import pandas as pd 
from pandas import Series, DataFrame
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

url = 'https://raw.githubusercontent.com/Sketchjar/MachineLearningHD/main/iris.csv'
df = load_iris(url)
iris.head()
iris.drop('Id',axis=1,inplace=True)
fig = iris[iris.Species == 'Iris-setosa'].plot(kind='scatter', x='SepalLengthCm', y='SepalWidthCm', color='orange', label='Setosa')
iris[iris.Species == 'Iris-versicolor'].plot(kind='scatter', x='SepalLengthCm', y='SepalWidthCm', color='blue', label='Versicolor', ax=fig)
iris[iris.Species == 'Iris-virginica'].plot(kind='scatter', x='SepalLengthCm', y='SepalWidthCm', color='green', label='Virginica', ax=fig)

fig.set_xlabel('Sepal Length')
fig.set_ylabel('Sepal Width')
fig.set_title('Sepal Length Vs Width')

fig=plt.gcf()
fig.set_size_inches(10, 7)
plt.show()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS