Professional Documents
Culture Documents
AP19110010030 R Lab-Assignment-6
AP19110010030 R Lab-Assignment-6
Kilaru Sravan
AP19110010030
CSE-A
Implementing K-Mediod
In [1]:
install.packages("cluster")
C:\Users\LENOVO\AppData\Local\Temp\RtmpGoFql6\downloaded_packages
In [2]:
install.packages("factoextra")
C:\Users\LENOVO\AppData\Local\Temp\RtmpGoFql6\downloaded_packages
localhost:8888/notebooks/AP19110010030_R_Lab-Assignment-6.ipynb 1/7
23/04/2022, 12:27 AP19110010030_R_Lab-Assignment-6 - Jupyter Notebook
In [4]:
library("ggplot2")
library("cluster")
library("factoextra")
data = read.csv("BMI.csv", header = TRUE)
head(data, 8)
In [5]:
Height Weight
174 96
189 87
185 110
195 104
149 61
189 104
147 92
154 111
localhost:8888/notebooks/AP19110010030_R_Lab-Assignment-6.ipynb 2/7
23/04/2022, 12:27 AP19110010030_R_Lab-Assignment-6 - Jupyter Notebook
In [6]:
localhost:8888/notebooks/AP19110010030_R_Lab-Assignment-6.ipynb 3/7
23/04/2022, 12:27 AP19110010030_R_Lab-Assignment-6 - Jupyter Notebook
In [7]:
From the above graph we can observe that 6 as the optimal number of clusters as there is a change of
slope
In [8]:
kmed = pam(df, k = 6)
localhost:8888/notebooks/AP19110010030_R_Lab-Assignment-6.ipynb 4/7
23/04/2022, 12:27 AP19110010030_R_Lab-Assignment-6 - Jupyter Notebook
In [9]:
174 96 1
189 87 1
185 110 1
195 104 1
149 61 2
189 104 1
147 92 3
154 111 3
localhost:8888/notebooks/AP19110010030_R_Lab-Assignment-6.ipynb 5/7
23/04/2022, 12:27 AP19110010030_R_Lab-Assignment-6 - Jupyter Notebook
In [10]:
localhost:8888/notebooks/AP19110010030_R_Lab-Assignment-6.ipynb 6/7