0% found this document useful (0 votes)
22 views2 pages

Cse3024: Web Mining Lab: Assessment - 5

This document contains a student's code submission for an assessment in their CSE3024: Web Mining Lab course. The code imports necessary libraries, loads the Iris dataset, performs k-means clustering on the dataset for values of k between 1 and 10, calculates the distortion for each k, and plots the distortions to find the optimal k via the elbow method. The code is authored by student Anubhav Bhandary with registration number 19BCE2483.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Cse3024: Web Mining Lab: Assessment - 5

This document contains a student's code submission for an assessment in their CSE3024: Web Mining Lab course. The code imports necessary libraries, loads the Iris dataset, performs k-means clustering on the dataset for values of k between 1 and 10, calculates the distortion for each k, and plots the distortions to find the optimal k via the elbow method. The code is authored by student Anubhav Bhandary with registration number 19BCE2483.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE3024: WEB MINING LAB

ASSESSMENT - 5

NAME: Anubhav Bhandary

Reg No: 19BCE2483

SLOT NO: L37-L38

CODE :
import numpy as np

import matplotlib.pyplot as plt

import pandas as pd

dataset=pd.read_csv("Iris.csv")
x=dataset.iloc[:,[1,2,3,4]].values

from sklearn.cluster import KMeans

distorVons = []
K = range(1,10)

for k in K:

kmeanModel = KMeans(n_clusters=k)

kmeanModel.fit(x)
distorVons.append(kmeanModel.inerVa_)

plt.figure(figsize=(16,8))

plt.plot(K, distorVons, 'bx-')


plt.xlabel('k')

plt.ylabel('DistorVon')

plt.Vtle('The Elbow Method showing the opVmal k')


plt.show()

19BCE2483
OUTPUT:

19BCE2483

You might also like