Clustering symbolic networks

# nVar - number of variables
# nVarP = nVar+1
# long - names of units
# SOs - set of units represented as symbolic objects
# numSO - number of symbolic objects (units)
# varCats - list with names variables and names of categories for each variable
# nCats - number of categories for each variable
# so - empty symbolic object
# namedSO - empty symbolic object with named components
# https://r-forge.r-project.org/R/?group_id=864
# C:/Users/batagelj/work/clamix/lynne/Billard2.R

> # source("C:\\Users\\batagelj\\work\\clamix\\clamix.R\\clamix3t.R")
> library(clamix)
> wdir <- 'E:/data/bike/CitiBike/csv/2015-16'
> setwd(wdir)
> T <- read.csv('SOsp.csv',head=TRUE,sep=';',stringsAsFactors=FALSE)
> numSO <- nrow(T)
> nVar <- 1; nVarP = nVar+1
> tripSO <- vector("list",nVar)
> varCats <- vector("list",nVar)
> varCats[[1]] <- names(T)[6:53]
> nCats <- sapply(varCats,length)
> names(varCats) <- c("flow")
> for(i in 1:nVar) varCats[[i]] <- c(varCats[[i]],"NA","num")
> so <- empty.symObject(nCats+1)
> namedSO <- so
> names(namedSO) <- names(varCats)
> for(i in 1:nVar) names(namedSO[[i]]) <- varCats[[i]]
> long <- paste(T$uName,"->",T$vName)
> save(nVar,nVarP,so,namedSO,numSO,long,varCats,file="./tripSO.meta")


> SOs <- vector("list",numSO)
> for(i in 1:numSO){
+    st <- so
+    tmp <- c(T[i,6:53],0,T[i,1]); names(tmp) <- NULL
+    st[[1]] <- unlist(tmp)
+    class(st) <- "symObject"
+    SOs[[i]] <- st
+ }
> names(SOs) <- long
> save(nVar,nVarP,so,numSO,SOs,file="./tripSOs.so")

> alpha <-rep(1/nVar,nVar)
> SyData <- list(SOs=SOs,so=so,namedSO=namedSO,alpha=alpha,type="fDist")

> hc <- hclustSO(SOs)
> plot(hc,hang=-1)
> cls7 <- cutree(hc,7)
> table(cls7)
cls7
  1   2   3   4   5   6   7 
192 105  95  49  37  60  51 
> rez <- leaderSO(SOs,20)

Drawing on A4 paper

> pdf("dendro7a4.pdf",width=11.7,height=8.3,paper="a4r")
> plot(hc,hang=-1,cex=0.1,lwd=0.1)
> dev.off()
notes/net/bikes/citi3.txt · Last modified: 2016/12/10 12:30 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki