_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › DBSCAN-R覯
|
|
--http://www.sthda.com/english/wiki/wiki.php?id_contents=7940
library("fpc") # Compute DBSCAN using fpc package set.seed(123) db <- fpc::dbscan(df, eps = 0.15, MinPts = 5) # Plot DBSCAN results plot(db, df, main = "DBSCAN", frame = FALSE) library(RODBC) conn <- odbcConnect("dw", uid = "user1", pwd = "pw") mydata <- sqlQuery(conn,"select * from test order by x") head(mydata) robustz <- function(x) { sigma <- IQR(x) / 1.35 if(sigma == 0) sigma <- sd(x) if(sigma == 0) sigma <- 0.00001 z <- (x - median(x)) / sigma return(z) } x <- mydata[, c("x", "y")] df <- mydata[, c("x", "y")] x$x <- robustz(x$cnt) x$y <- robustz(x$ccu_avg) library("fpc") cl <- fpc::dbscan(x, eps = 0.30, MinPts = 5) plot(cl, df, main = "DBSCAN", frame = FALSE)
鏤
|
れる 襷 覓朱慨る 蟆 覈襷襴 豢譴. |