当前位置:网站首页>Cluster Analysis in R Simplified and Enhanced
Cluster Analysis in R Simplified and Enhanced
2022-07-02 11:43:00 【Xiaoyu 2022】
install.packages("factoextra")
library(factoextra)
# Load and scale the dataset
data("USArrests")
df <- scale(USArrests)
head(df)
library(factoextra)
# Correlation-based distance method
res.dist <- get_dist(df, method = "pearson")
head(round(as.matrix(res.dist), 2))[, 1:6]
# Visualize the dissimilarity matrix
fviz_dist(res.dist, lab_size = 8)
# Load and scale the dataset
data("USArrests")
df <- scale(USArrests)
# Compute dissimilarity matrix
res.dist <- dist(df, method = "euclidean")
# Compute hierarchical clustering
res.hc <- hclust(res.dist, method = "ward.D2")
# Visualize
plot(res.hc, cex = 0.5)
eclust(x, FUNcluster = "kmeans", hc_metric = "euclidean", ...)
library("factoextra")
# Enhanced k-means clustering
res.km <- eclust(df, "kmeans", nstart = 25)
library("factoextra")
# Gap statistic plot
fviz_gap_stat(res.km$gap_stat)
library("factoextra")
# Silhouette plot
fviz_silhouette(res.km)
library("factoextra")
res.hc <- eclust(df, "hclust") # compute hclust
fviz_dend(res.hc, rect = TRUE) # dendrogam
library("factoextra")
fviz_silhouette(res.hc) # silhouette plot
library("factoextra")
fviz_cluster(res.hc) # scatter plot
边栏推荐
- JS -- take a number randomly from the array every call, and it cannot be the same as the last time
- TIPC addressing 2
- Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
- 揭露数据不一致的利器 —— 实时核对系统
- Order by注入
- TDSQL|就业难?腾讯云数据库微认证来帮你
- CTF record
- Develop scalable contracts based on hardhat and openzeppelin (II)
- 念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
- PKG package manager usage instance in FreeBSD
猜你喜欢
tidb-dm报警DM_sync_process_exists_with_error排查
Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
抖音海外版TikTok:正与拜登政府敲定最终数据安全协议
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
[idea] use the plug-in to reverse generate code with one click
Solve the problem of data blank in the quick sliding page of the uniapp list
ren域名有价值吗?值不值得投资?ren域名的应用范围有哪些?
PHP tea sales and shopping online store
mmrotate旋转目标检测框架使用记录
随机推荐
解决uniapp列表快速滑动页面数据空白问题
Basic usage of MySQL in centos8
Solve the problem of data blank in the quick sliding page of the uniapp list
Internship report skywalking distributed link tracking?
Pit of the start attribute of enumrate
Always report errors when connecting to MySQL database
原生方法合并word
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
Liftover for genome coordinate conversion
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
ctf 记录
mmrotate旋转目标检测框架使用记录
The working day of the month is calculated from the 1st day of each month
基于Hardhat编写合约测试用例
sqlite 修改列类型
ros缺少catkin_pkg
Homer forecast motif
String (Analog
VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘