getOptimalMarkovChain: Generates the optimal markov chains from a list of markov...

View source: R/ClusterOptimization.r

getOptimalMarkovChainR Documentation

Generates the optimal markov chains from a list of markov chains and corresponding clusters

Description

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.

Usage

getOptimalMarkovChain(startPattern, markovchains, clusters)

Arguments

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).

Author(s)

Theo van Kraay theo.vankraay@hotmail.com

Examples


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)

clickstream documentation built on Sept. 27, 2023, 5:06 p.m.