当前位置:网站首页>Seriation in R: How to Optimally Order Objects in a Data Matrice
Seriation in R: How to Optimally Order Objects in a Data Matrice
2022-07-02 09:38:00 【小宇2022】
library(seriation)
# Load the data
data("iris")
df <- iris
head(df, 2)
# Remove the column `species` (column 5)
df <- df[, -5]
# Reorder the objects randomly
set.seed(123)
df <- df[sample(seq_len(nrow(df))),]
head(df, 2)
# Compute dissimilarity matrix
dist_result <- dist(df)
# Seriate objects, reorder rows based on their similarity
object_order <- seriate(dist_result)
# Extract object orders
head(get_order(object_order), 15)
pimage(dist_result, main = "Random order")
library(seriation)
# Load the data
data("iris")
df <- iris
head(df, 2)
# Remove the column `species` (column 5)
df <- df[, -5]
# Reorder the objects randomly
set.seed(123)
df <- df[sample(seq_len(nrow(df))),]
head(df, 2)
# Compute dissimilarity matrix
dist_result <- dist(df)
# Seriate objects, reorder rows based on their similarity
object_order <- seriate(dist_result)
# Extract object orders
head(get_order(object_order), 15)
pimage(dist_result, order = object_order, main = "Reordered")
library(seriation)
# Data preparation
# Load the dataset
data("USArrests")
# Replace original values by their ranks
df <- head(apply(USArrests, 2, rank), 30)
# Perform seriation on row and columns
row_order <- seriate(dist(df, "minkowski", p = 1), method ="TSP")
col_order <- seriate(dist(t(df), "minkowski", p = 1), method ="TSP")
orders <- c(row_order, col_order)
# Visualization: matrix of bars
# Original matrix
bertinplot(df)
library(seriation)
# Data preparation
# Load the dataset
data("USArrests")
# Replace original values by their ranks
df <- head(apply(USArrests, 2, rank), 30)
# Perform seriation on row and columns
row_order <- seriate(dist(df, "minkowski", p = 1), method ="TSP")
col_order <- seriate(dist(t(df), "minkowski", p = 1), method ="TSP")
orders <- c(row_order, col_order)
# Visualization: matrix of bars
# Original matrix
bertinplot(df, orders)
library(seriation)
# Load demo data
data("Townships")
# Visualize the original data
bertinplot(
Townships,
options = list(panel = panel.circles)
)
library(seriation)
# Load demo data
data("Townships")
# Seriate rows and columns using the bond energy algorithm (BEA)
set.seed(1234)
orders <- seriate(Townships, method = "BEA", control = list(rep = 10))
bertinplot(
Townships, order = orders,
options = list(panel = panel.circles)
)
边栏推荐
- 基于Hardhat和Openzeppelin开发可升级合约(二)
- 抖音海外版TikTok:正与拜登政府敲定最终数据安全协议
- ros缺少catkin_pkg
- C#基于当前时间,获取唯一识别号(ID)的方法
- Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
- The difference between SQL left join main table restrictions written after on and where
- 基于Hardhat和Openzeppelin开发可升级合约(一)
- Wechat applet uses Baidu API to achieve plant recognition
- Develop scalable contracts based on hardhat and openzeppelin (II)
- 【IDEA】使用插件一键逆向生成代码
猜你喜欢
2022年遭“挤爆”的三款透明LED显示屏
On April 17, 2022, the five heart matchmaker team received double good news
What is the relationship between digital transformation of manufacturing industry and lean production
RPA进阶(二)Uipath应用实践
【IDEA】使用插件一键逆向生成代码
PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)
MySQL comparison operator in problem solving
Multi line display and single line display of tqdm
Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
由粒子加速器产生的反中子形成的白洞
随机推荐
map集合赋值到数据库
Redis超出最大内存错误OOM command not allowed when used memory &gt; 'maxmemory'
RPA进阶(二)Uipath应用实践
TIPC Service and Topology Tracking4
Summary of data export methods in powerbi
程序员成长第六篇:如何选择公司?
STM32 single chip microcomputer programming learning
liftOver进行基因组坐标转换
webauthn——官方开发文档
ASTParser 解析含有emum 枚举方法的类文件的踩坑记
PowerBI中导出数据方法汇总
Wechat applet uses Baidu API to achieve plant recognition
tidb-dm报警DM_sync_process_exists_with_error排查
基于Hardhat和Openzeppelin开发可升级合约(一)
Tdsql | difficult employment? Tencent cloud database micro authentication to help you
启牛商学院给的股票账户安全吗?能开户吗?
mysql链表数据存储查询排序问题
PHP tea sales and shopping online store
What is the relationship between digital transformation of manufacturing industry and lean production
sqlite 修改列类型