View source: R/ClusterOptimization.r
getOptimalMarkovChain | R Documentation |
The purpose of this function is to predict from a pattern using pre-computed markov chains and corresponding clusters. The markov chain corresponding with the cluster that is the best fit to the prediction value is used.
getOptimalMarkovChain(startPattern, markovchains, clusters)
startPattern |
The pattern object to be used. |
markovchains |
The pre-computed markov chains generated from a set of clusters. |
clusters |
The corresponding clusters (should be in the corresponding order as the markov chains). |
Theo van Kraay theo.vankraay@hotmail.com
training <- c("User1,h,c,c,p,c,h,c,p,p,c,p,p,o",
"User2,i,c,i,c,c,c,d",
"User3,h,i,c,i,c,p,c,c,p,c,c,i,d",
"User4,c,c,p,c,d")
test <- c("User1,h,c,c,p,p,h,c,p,p,c,p,p,o",
"User2,i,c,i,c,c,c,d",
"User4,c,c,c,c,d")
trainingCLS <- as.clickstreams(training, header = TRUE)
testCLS <- as.clickstreams(test, header = TRUE)
clusters <- clusterClickstreams(trainingCLS, centers = 2)
markovchains <- fitMarkovChains(clusters, order = 1)
startPattern <- new("Pattern", sequence = c("c"))
mc <- getOptimalMarkovChain(startPattern, markovchains, clusters)
predict(mc, startPattern)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.