测试验证环境


数据: 7w+ 条,数据结构如下图:

> head(car.train)
DV DC RV RC SOC HV LV HT LT Type TypeName
1 379 85.09 0.00 0.0 62.99 3.99 0.00 12 0 10f689e8-e6cc-47a3-be5a-dbc3833428ef EV200
2 379 85.09 370.89 59.9 63.99 4.01 0.00 12 0 10f689e8-e6cc-47a3-be5a-dbc3833428ef EV200
3 379 85.09 0.00 0.0 64.99 4.01 0.00 12 0 10f689e8-e6cc-47a3-be5a-dbc3833428ef EV200
4 379 85.09 0.00 0.0 66.00 4.03 1.55 12 11 10f689e8-e6cc-47a3-be5a-dbc3833428ef EV200
5 379 85.09 0.00 0.0 67.00 4.03 0.00 12 0 10f689e8-e6cc-47a3-be5a-dbc3833428ef EV200
6 379 85.09 0.00 0.0 68.00 4.05 0.00 13 0 10f689e8-e6cc-47a3-be5a-dbc3833428ef EV200

机器配置:

R version:

> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 2.5
year 2016
month 04
day 14
svn rev 70478
language R
version.string R version 3.2.5 (2016-04-14)
nickname Very, Very Secure Dishes

R包性能对比


全局函数及参数设置

##----------------------全局设置-------------------------------
remove(list=ls())
space_path <- c("E:\\RScore\\kmeans\\")
setwd(space_path)
Sys.setlocale(category = "LC_ALL",local="chinese") ##table 行列转换函数
tblView <- function (tbl)
{
##install.packages("tidyr")
library(tidyr)
df <- as.data.frame(tbl)
df <- spread(data = df, key = Var2, value = Freq)
datatable(df)
} ## 公共函数:数据读写及计算
source("core.R",encoding="utf-8")
teld.ml.init() ##训练样本
car.train <- teld.ml.rQuery("D_Cluster")
newdata <- car.train[1:8]

stats::kmeans


source code:

> ################################################stats::kmeans######################################
> startTime <- Sys.time();
>
> library(stats)
> kc <- kmeans(x=newdata, centers = 13)
> #plot(newdata[,c("DV","DC")],col=kc$cluster)
> tbl <- table(car.train$TypeName,kc$cluster)
> tblView(tbl)
>
> ##耗时间
> endTime <- Sys.time()
> difTime <- difftime(endTime,startTime,units = "secs")
> print(paste0("stats::kmeans total time:", difTime))
[1] "stats::kmeans total time:0.195545196533203"
stats::kmeans total time:0.195545196533203, result view:

fpc::kmeansruns


source code:

> ################################################fpc::kmeansruns######################################
> startTime <- Sys.time();
>
> library(fpc)
> kc1 <- kmeansruns(data = newdata,krange = 1:15,critout = TRUE)
2 clusters 9394.437
3 clusters 185919.7
4 clusters 482630.4
5 clusters 414875.3
6 clusters 376338
7 clusters 334493.6
8 clusters 303976.7
9 clusters 279036.3
10 clusters 432009.9
11 clusters 363074.8
12 clusters 405784.7
13 clusters 397422.8
14 clusters 371842.5
15 clusters 408561.7
Warning messages:
1: Quick-TRANSfer stage steps exceeded maximum (= 3507150)
2: Quick-TRANSfer stage steps exceeded maximum (= 3507150)
3: Quick-TRANSfer stage steps exceeded maximum (= 3507150)
> tbl<- table(car.train$TypeName,kc1$cluster)
> tblView(tbl)
>
> ##耗时间
> endTime <- Sys.time()
> difTime <- difftime(endTime,startTime,units = "secs")
> print(paste0("fpc::kmeansruns total time:", difTime))
[1] "fpc::kmeansruns total time:107.454074859619"
[1] "fpc::kmeansruns total time:107.454074859619"  result view:

cluster::pam


source code

> ################################################cluster::pam######################################
>
> library(cluster)
> cPam <- pam(x=newdata,k=13)
Error in pam(x = newdata, k = 13) :
have 70143 observations, but not more than 65536 are allowed

Error: 待确认

fpc::pamk


source code

> ################################################fpc::pamk######################################
>
> library(fpc)
> fPamk <- pamk(newdata,krang=1:15)
Error in pam(sdata, k, diss = diss, ...) :
have 70143 observations, but not more than 65536 are allowed

Error: 待确认

stats::hclust


source code:

################################################fpc::pamk######################################
>
> library(fpc)
> fPamk <- pamk(newdata,krang=1:15)
Error in pam(sdata, k, diss = diss, ...) :
have 70143 observations, but not more than 65536 are allowe

Error: 待确认

mclust::Mclust


source code:

> ################################################mclust::Mclust######################################
> library(mclust)
> EM<-Mclust(newdata)
Error in hcVVV(data = c(379, 379, 379, 379, 379, 379, 379, 379, 379, 379, :
NAs in foreign function call (arg 13)
In addition: Warning message:
In hcVVV(data = c(379, 379, 379, 379, 379, 379, 379, 379, 379, 379, :
NAs introduced by coercion to integer range

Error: 待确认

cluster::fanny


source code:

> ################################################cluster::fanny######################################
> library(cluster)
> fannyz=fanny(newdata,13,metric="SqEuclidean")
Error in fanny(newdata, 13, metric = "SqEuclidean") :
long vectors (argument 5) are not supported in .Fortran

Error: 待确认

e1071::cmeans


source code:

> ################################################e1071::cmeans######################################
> startTime <- Sys.time();
>
> library("e1071")
> eCm<-cmeans(newdata,15)
> tbl <- table(car.train$TypeName,eCm$cluster)
> tblView(tbl)
>
> ##耗时间
> endTime <- Sys.time()
> difTime <- difftime(endTime,startTime,units = "secs")
> print(paste0("stats::kmeans total time:", difTime))
[1] "stats::kmeans total time:8.7237401008606"

[1] "stats::kmeans total time:8.7237401008606"   result view:

待验证


ML: 聚类算法R包-对比的更多相关文章

  1. ML: 聚类算法R包 - 模型聚类

    模型聚类 mclust::Mclust RWeka::Cobweb mclust::Mclust EM算法也称为期望最大化算法,在是使用该算法聚类时,将数据集看作一个有隐形变量的概率模型,并实现模型最 ...

  2. ML: 聚类算法R包-层次聚类

    层次聚类 stats::hclust stats::dist    R使用dist()函数来计算距离,Usage: dist(x, method = "euclidean", di ...

  3. ML: 聚类算法R包-模糊聚类

    1965年美国加州大学柏克莱分校的扎德教授第一次提出了'集合'的概念.经过十多年的发展,模糊集合理论渐渐被应用到各个实际应用方面.为克服非此即彼的分类缺点,出现了以模糊集合论为数学基础的聚类分析.用模 ...

  4. ML: 聚类算法R包-网格聚类

    网格聚类算法 optpart::clique optpart::clique CLIQUE(Clustering In QUEst)是一种简单的基于网格的聚类方法,用于发现子空间中基于密度的簇.CLI ...

  5. ML: 聚类算法R包-K中心点聚类

    K-medodis与K-means比较相似,但是K-medoids和K-means是有区别的,不一样的地方在于中心点的选取,在K-means中,我们将中心点取为当前cluster中所有数据点的平均值, ...

  6. ML: 聚类算法R包 - 密度聚类

    密度聚类 fpc::dbscan fpc::dbscan DBSCAN核心思想:如果一个点,在距它Eps的范围内有不少于MinPts个点,则该点就是核心点.核心和它Eps范围内的邻居形成一个簇.在一个 ...

  7. ML: 聚类算法-K均值聚类

    基于划分方法聚类算法R包: K-均值聚类(K-means)                   stats::kmeans().fpc::kmeansruns() K-中心点聚类(K-Medoids) ...

  8. ML: 聚类算法-概论

    聚类分析是一种重要的人类行为,早在孩提时代,一个人就通过不断改进下意识中的聚类模式来学会如何区分猫狗.动物植物.目前在许多领域都得到了广泛的研究和成功的应用,如用于模式识别.数据分析.图像处理.市场研 ...

  9. 【转】利用python的KMeans和PCA包实现聚类算法

    转自:https://www.cnblogs.com/yjd_hycf_space/p/7094005.html 题目: 通过给出的驾驶员行为数据(trip.csv),对驾驶员不同时段的驾驶类型进行聚 ...

随机推荐

  1. Kafka的安装 -- 未完成

    1. 官网下载软件 2. linux服务器上, 安装上传和下载的工具 yum install -y lrzsz rz : 上传 sz + 文件名 : 下载 3.解压文件 pwd: 查看当前路径 解压到 ...

  2. [工作日志]2018-11-15 主要: 改bug

    map不能直接转string格式 *方法: Map<String,Object> map=new HashMap<String,Object>(); map.put(" ...

  3. 1.带宽&吞吐量

    1.带宽         网络带宽是指在一个固定的时间内(1秒),能通过的最大位数据.就好象高速公路的车道一样,带宽越大,好比车道越多 带宽是一个非常有用的概念,在网络通信中的地位十分重要.带宽的实际 ...

  4. 微软Power BI 每月功能更新系列——9月Power BI 新功能学习

    Power BI Desktop 9月新功能摘要 Power BI 9月更新如期而至,这一次Power BI 又推出了新功能——聚合预览,它可在内存中无缝地存储汇总值,大大提高报告的性能.另外本月还包 ...

  5. Python学习笔记第六周

    目录 一.基础概念 面向对象编程 1.面向对象的几个核心特点 1.class类 2.object对象 3.encapsulation封装 4.inheritance继承 5.polymorphism多 ...

  6. tmux学习

    1.基本命令: http://blog.chinaunix.net/uid-26285146-id-3252286.html (重要) http://blog.csdn.net/longxibendi ...

  7. 【leetcode】21-MergeTwoSortedLists

    problem MergeTwoSortedLists 一种方法是迭代,一种方法是递归: code /** * Definition for singly-linked list. * struct ...

  8. golang相关网摘

    1.golang开发50个坑 http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/index.html#mli ...

  9. Gym.101908 Brazil Subregional Programming Contest(寒假自训第六场)

    这几天睡眠时间都不太够,室友晚上太会折腾了,感觉有点累,所以昨天的题解也没写,看晚上能不能补起来. B . Marbles 题意:给定N组数(xi,yi),玩家轮流操作,每次玩家可以选择其中一组对其操 ...

  10. loadrunner笔记---一

    1.Loadrunner主要由Vugen,Controller和Analyais3部分组成 2.简述描述集合点和集合点函数 集合点可以同步虚拟用户,以便能在同一时刻执行任务,集合点函数lr_rende ...