<jupyter_start><jupyter_text>KMeans Algorithm on Iris DataSet<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sn
import pylab as pl

from sklearn.datasets import load_iris
Data = load_iris()
Data.data[0:5]
Data.target
Data.feature_names
Data.target_names
x = Data.data
x[0 :2]
plt.scatter(x[:, 0], x[:, 3], marker = '*', color = 'k')
from sklearn.cluster import KMeans
clt = KMeans(init='k-means++', n_clusters = 3)
clt.fit(x)
x[0:5]
clt.labels_
predict = clt.predict(x)
predict[0:5]
clt.cluster_centers_
clt.inertia_
clt.n_clusters
clt.score(x, predict)<jupyter_output><empty_output><jupyter_text>DBSCAN Algorithm on Iris Dataset<jupyter_code>from sklearn.cluster import DBSCAN
db = DBSCAN(eps = 1, min_samples = 10)
db.fit(x)
db.core_sample_indices_[0:5]
db.eps
db.labels_<jupyter_output><empty_output><jupyter_text>Agglomerative hierarchial clustering<jupyter_code>from sklearn.cluster import AgglomerativeClustering
hi = AgglomerativeClustering(n_clusters = 3)
hi.fit(x)
hi.labels_
hi.n_clusters
hi.n_clusters_
import scipy.cluster.hierarchy as shc
plt.figure(figsize=(10, 7))  
plt.title("Dendrograms")  
dend = shc.dendrogram(shc.linkage(x, method='ward'))
plt.axhline(y=4, color='r', linestyle='--')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1263565891472868, 'fraction_numerical': 0.01627906976744186, 'mean_word_length': 7.06875, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '414320', 'license': 'Apache-2.0', 'n_tokens_mistral': 551, 'n_tokens_neox': 527, 'n_words': 105, 'path': 'Iris Clustering.ipynb', 'repo_name': 'Raghu010/Clusteing-the-Iris-Data', 'size': '1290'}