楼主: 亲爱的喜芽
2692 0

[问答] R语言:dtwclust包里面,修改dist默认的选项 [推广有奖]

  • 0关注
  • 1粉丝

已卖:74份资源

本科生

44%

还不是VIP/贵宾

-

威望
0
论坛币
101 个
通用积分
1.2600
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1302 点
帖子
24
精华
0
在线时间
112 小时
注册时间
2015-3-31
最后登录
2025-12-18

楼主
亲爱的喜芽 发表于 2018-2-5 19:34:26 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
1。distmatrix<-dist(ret1,method = "dtw")
2.dtw(a,b, step=symmetric1,window.size=3L,window.type="sakoechiba", keep=T);
在1中计算距离矩阵的时候想用dtw这个方法,但是想改一下dtw默认的选项,哪位大神知道的话,求帮助



# ====================================================================================
# Registering a custom distance with the 'proxy' package and using it
# ====================================================================================

# Normalized asymmetric DTW distance
ndtw <- function(x, y, ...) {
    dtw::dtw(x, y, step.pattern = asymmetric,
             distance.only = TRUE, ...)$normalizedDistance
}

# Registering the function with 'proxy'
if (!pr_DB$entry_exists("nDTW"))
    proxy::pr_DB$set_entry(FUN = ndtw, names=c("nDTW"),
                           loop = TRUE, type = "metric", distance = TRUE,
                           description = "Normalized asymmetric DTW")

# Subset of (original) data for speed
pc.ndtw <- tsclust(series[-1L], k = 4L,
                   distance = "nDTW",
                   seed = 8319,
                   trace = TRUE,
                   args = tsclust_args(dist = list(window.size = 18L)))

# Which cluster would the first series belong to?
# Notice that newdata is provided as a list
predict(pc.ndtw, newdata = series[1L])


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:CLU Dis IST R语言 matrix

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-9 04:26