R/Sir, i am trying to find precision
and recall value for multi class software clustering problem using package
"ClusterCrit"i have attached my source code
"Clustering.txt" and input files "ClassCoupling.txt" &
"JUnitGoldStandard"in my script for different combination of
clustering i am getting same value of precision & recall, which i think
should not be?Kindly helpThanks in advanceAMIT RATHEEResearch Scholar
value2 = as.integer()
HierarchicalClustering <- function(couplingdata, tcluster, met="complete")
{
d <- dist(as.matrix(couplingdata))
dendrogram <- hclust(d, method = met)
plot(dendrogram, check = TRUE, labels = colnames(couplingdata))
rect.hclust(dendrogram,k = tcluster, border = 2)
# making clusters variable as global
clusters <<- cutree(dendrogram, k= tcluster)
clusters
}
Precision <- function(observed, gold1)
{
library(clusterCrit)
print(observed)
print(gold1)
ext <- extCriteria(observed, gold1,"all")
return(ext)
}
Recall <- function(observed, gold1)
{
library(clusterCrit)
value2 <- as.numeric(extCriteria(observed, gold1,"Recall"))
return(value2)
}
# initialization of variables
totalClusters = 4
method = "ward.D2"
goldStandard = as.integer(JUnitGoldStandard)
# performing hierarchical clustering
HierarchicalClustering(ClassCouplingData, totalClusters, method)
# generating all possible permutations
val <- vector()
library(combinat)
for(i in 1: totalClusters)
val <- c(val, i)
permutation <- permn(val)
# evaluating clustering obtained
for(i in 1: length(permutation))
{
str2 = ""
library(car)
print(permutation[i])
gold1 <-
as.integer(recode(goldStandard,"1=permutation[[i]][1];2=permutation[[i]][2];3=permutation[[i]][3];
4=permutation[[i]][4]"),as.numeric.result=FALSE)
precision = 0
ext <- Precision(clusters, gold1)
recall = Recall(clusters, gold1)
cat("Iteration = ", i, " Precision = ", ext$precision," Recall= ",recall,
"\n")
}
1 0.004 0 0.308 0.058 0.016 0.178 0.146 0.19 0.254
0.339 0.388 0.224 0.137 0.358 0.404 0.355 0.396 0.297 0.301
0.065 0.171 0.667 0.718 0.576 0.265 0.421 0.487 0.43 0.605
0.224 1.151
0.004 1 0.363 0.072 0.485 0.8 0.022 0.084 0.001 0.006
0.003 0.004 0.015 0.004 0.003 0.071 0.031 0.034 0.021 0.013
0.027 0.007 0.004 0.501 0.206 0.137 0.058 0.041 0.036 0.057
0.004 0.128
0 0.363 1 0.074 0 0.388 0.002 0.068 0 0
0.027 0 0.269 0 0 0.102 0.114 0.058 0.022 0.016
0 0.126 0 0.018 0 0.326 0.246 0.269 0.065 0.012
0 0.011
0.308 0.072 0.074 1 0.11 0.148 0.261 0.386 0.213 0.276
0.281 0.283 0.205 0.079 0.214 0.24 0.457 0.267 0.194 0.237
0.049 0.14 0.276 0.62 0.341 0.422 0.404 0.343 0.304 0.941
0.136 0.773
0.058 0.485 0 0.11 1 0.806 0.035 0.099 0 0.144
0.024 0.109 0 0.006 0.108 0.045 0.047 0.005 0.041 0.001
0.013 0 0.022 0.076 0.118 0.112 0.02 0.096 0.022 0.04
0.011 0.046
0.016 0.8 0.388 0.148 0.806 1 0.063 0.27 0.01 0.122
0.063 0.139 0.052 0.016 0.066 0.11 0.129 0.055 0.04 0.048
0.015 0.029 0.004 0.075 0.07 0.23 0.042 0.08 0.031 0.037
0 0.096
0.178 0.022 0.002 0.261 0.035 0.063 1 0.429 0.322 0.887
1.114 0.463 0.112 0.051 0.123 0.282 0.176 0.416 0.426 0.36
0.729 0.2 0.202 0.361 0.221 0.176 0.182 0.215 0.169 0.3
0.073 0.403
0.146 0.084 0.068 0.386 0.099 0.27 0.429 1 0.228 0.422
0.581 0.469 0.253 0.053 0.157 0.366 0.425 0.384 0.262 0.496
0.162 0.274 0.159 0.293 0.233 0.801 0.173 0.221 0.151 0.249
0.09 0.343
0.19 0.001 0 0.213 0 0.01 0.322 0.228 1 0.553
0.294 0.244 0.441 0.085 0.129 0.256 0.148 0.37 0.257 0.476
0.225 0.247 0.239 0.265 0.229 0.13 0.168 0.202 0.213 0.292
0.105 0.194
0.254 0.006 0 0.276 0.144 0.122 0.887 0.422 0.553 1
1.003 0.645 0.284 0.058 0.22 0.197 0.276 0.444 0.623 0.387
0.342 0.092 0.463 0.313 0.341 0.236 0.21 0.288 0.191 0.317
0.11 0.336
0.339 0.003 0.027 0.281 0.024 0.063 1.114 0.581 0.294 1.003
1 0.877 0.209 0.059 0.2 0.261 0.264 0.717 0.395 0.549
0.184 0.115 0.524 0.411 0.381 0.248 0.349 0.637 0.301 0.417
0.128 0.733
0.388 0.004 0 0.283 0.109 0.139 0.463 0.469 0.244 0.645
0.877 1 0.211 0.098 0.371 0.356 0.368 0.514 0.356 0.351
0.154 0.162 0.601 0.481 0.541 0.369 0.348 0.418 0.327 0.469
0.19 0.45
0.224 0.015 0.269 0.205 0 0.052 0.112 0.253 0.441 0.284
0.209 0.211 1 0.041 0.143 0.223 0.166 0.268 0.181 0.253
0.057 0.346 0.252 0.307 0.274 0.366 0.265 0.265 0.231 0.345
0.135 0.284
0.137 0.004 0 0.079 0.006 0.016 0.051 0.053 0.085 0.058
0.059 0.098 0.041 1 0.108 0.186 0.115 0.129 0.11 0.128
0.012 0.093 0.399 0.228 0.182 0.075 0.105 0.486 0.13 0.176
0.434 0.123
0.358 0.003 0 0.214 0.108 0.066 0.123 0.157 0.129 0.22
0.2 0.371 0.143 0.108 1 0.302 0.342 0.255 0.2 0.194
0.046 0.156 0.471 0.393 1.005 0.235 0.275 0.45 0.296 0.389
0.205 0.331
0.404 0.071 0.102 0.24 0.045 0.11 0.282 0.366 0.256 0.197
0.261 0.356 0.223 0.186 0.302 1 0.317 0.612 0.384 0.344
0.185 0.256 0.542 0.48 0.472 0.269 0.365 0.469 0.422 0.468
0.202 0.372
0.355 0.031 0.114 0.457 0.047 0.129 0.176 0.425 0.148 0.276
0.264 0.368 0.166 0.115 0.342 0.317 1 0.328 0.246 0.264
0.056 0.164 0.445 0.413 0.446 0.715 0.52 1.226 0.344 0.76
0.16 0.417
0.396 0.034 0.058 0.267 0.005 0.055 0.416 0.384 0.37 0.444
0.717 0.514 0.268 0.129 0.255 0.612 0.328 1 0.619 1.277
0.214 0.243 0.454 0.521 0.452 0.376 0.492 0.552 0.488 0.504
0.201 0.426
0.297 0.021 0.022 0.194 0.041 0.04 0.426 0.262 0.257 0.623
0.395 0.356 0.181 0.11 0.2 0.384 0.246 0.619 1 0.414
0.129 0.317 0.31 0.328 0.311 0.224 0.401 0.581 0.479 0.326
0.141 0.24
0.301 0.013 0.016 0.237 0.001 0.048 0.36 0.496 0.476 0.387
0.549 0.351 0.253 0.128 0.194 0.344 0.264 1.277 0.414 1
0.237 0.451 0.385 0.386 0.34 0.189 0.255 0.294 0.319 0.455
0.158 0.324
0.065 0.027 0 0.049 0.013 0.015 0.729 0.162 0.225 0.342
0.184 0.154 0.057 0.012 0.046 0.185 0.056 0.214 0.129 0.237
1 0.155 0.076 0.124 0.092 0.08 0.077 0.089 0.099 0.114
0.027 0.096
0.171 0.007 0.126 0.14 0 0.029 0.2 0.274 0.247 0.092
0.115 0.162 0.346 0.093 0.156 0.256 0.164 0.243 0.317 0.451
0.155 1 0.208 0.234 0.186 0.266 0.124 0.218 0.229 0.248
0.111 0.172
0.667 0.004 0 0.276 0.022 0.004 0.202 0.159 0.239 0.463
0.524 0.601 0.252 0.399 0.471 0.542 0.445 0.454 0.31 0.385
0.076 0.208 1 0.76 0.904 0.296 0.485 0.653 0.508 0.932
0.286 1.273
0.718 0.501 0.018 0.62 0.076 0.075 0.361 0.293 0.265 0.313
0.411 0.481 0.307 0.228 0.393 0.48 0.413 0.521 0.328 0.386
0.124 0.234 0.76 1 0.676 0.378 0.524 0.743 0.507 0.911
0.448 1.748
0.576 0.206 0 0.341 0.118 0.07 0.221 0.233 0.229 0.341
0.381 0.541 0.274 0.182 1.005 0.472 0.446 0.452 0.311 0.34
0.092 0.186 0.904 0.676 1 0.375 0.536 0.593 0.526 0.667
0.622 0.581
0.265 0.137 0.326 0.422 0.112 0.23 0.176 0.801 0.13 0.236
0.248 0.369 0.366 0.075 0.235 0.269 0.715 0.376 0.224 0.189
0.08 0.266 0.296 0.378 0.375 1 0.369 1.109 0.291 0.359
0.145 0.425
0.421 0.058 0.246 0.404 0.02 0.042 0.182 0.173 0.168 0.21
0.349 0.348 0.265 0.105 0.275 0.365 0.52 0.492 0.401 0.255
0.077 0.124 0.485 0.524 0.536 0.369 1 1.678 0.623 0.556
0.182 0.528
0.487 0.041 0.269 0.343 0.096 0.08 0.215 0.221 0.202 0.288
0.637 0.418 0.265 0.486 0.45 0.469 1.226 0.552 0.581 0.294
0.089 0.218 0.653 0.743 0.593 1.109 1.678 1 0.635 0.926
0.349 0.629
0.43 0.036 0.065 0.304 0.022 0.031 0.169 0.151 0.213 0.191
0.301 0.327 0.231 0.13 0.296 0.422 0.344 0.488 0.479 0.319
0.099 0.229 0.508 0.507 0.526 0.291 0.623 0.635 1 0.563
0.2 0.457
0.605 0.057 0.012 0.941 0.04 0.037 0.3 0.249 0.292 0.317
0.417 0.469 0.345 0.176 0.389 0.468 0.76 0.504 0.326 0.455
0.114 0.248 0.932 0.911 0.667 0.359 0.556 0.926 0.563 1
0.258 1.024
0.224 0.004 0 0.136 0.011 0 0.073 0.09 0.105 0.11
0.128 0.19 0.135 0.434 0.205 0.202 0.16 0.201 0.141 0.158
0.027 0.111 0.286 0.448 0.622 0.145 0.182 0.349 0.2 0.258
1 0.214
1.151 0.128 0.011 0.773 0.046 0.096 0.403 0.343 0.194 0.336
0.733 0.45 0.284 0.123 0.331 0.372 0.417 0.426 0.24 0.324
0.096 0.172 1.273 1.748 0.581 0.425 0.528 0.629 0.457 1.024
0.214 1
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.