Learn R Programming

clickstream (version 1.1.5)

predict-methods: Predicts the Next Click(s) of a User

Description

Predicts the Next Click(s) of a User

Usage

## S3 method for class 'MarkovChain':
predict(object, startPattern, dist = 1,
  ties = "random")

Arguments

object
The MarkovChain used for predicting the next click(s)
startPattern
Starting clicks of a user as Pattern object. A Pattern with an empty sequence is also possible.
dist
(Optional) The number of clicks that should be predicted (default is 1).
ties
(Optional) The strategy for handling ties in predicting the next click. Possible strategies are random (default) and first.

See Also

fitMarkovChain

Examples

Run this code
# fitting a simple Markov chain and predicting the next click
clickstreams <- 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",
               "User5,h,c,c,p,p,c,p,p,p,i,p,o",
               "User6,i,h,c,c,p,p,c,p,c,d")
csf <- tempfile()
writeLines(clickstreams, csf)
cls <- readClickstreams(csf, header = TRUE)
mc <- fitMarkovChain(cls)
startPattern <- new("Pattern", sequence = c("h", "c"))
predict(mc, startPattern)
#
# predict with predefined absorbing probabilities
#
startPattern <- new("Pattern", sequence = c("h", "c"),
        absorbingProbabilities = data.frame(d = 0.2, o = 0.8))
predict(mc, startPattern)

Run the code above in your browser using DataLab