predict,MarkovChain-method | R Documentation |
Predicts the Next Click(s) of a User
## S4 method for signature 'MarkovChain'
predict(object, startPattern, dist = 1, ties = "random")
object |
The |
startPattern |
Starting clicks of a user as |
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 |
This method predicts the next click(s) of a user.
The first clicks of a user
are given as Pattern
object. The next click(s) are predicted based on
the transition probabilities in the MarkovChain
object. The
probability distribution of the next click (n) is estimated as follows:
X^{(n)}=B \cdot \sum_{i=1}^k \lambda_iQ_iX^{(n-i)}
The distribution of states at time n
is given as
X^n
. The transition matrix for lag i
is given as Q_i
.
\lambda_i
specifies the lag parameter and B
the absorbing
probability matrix.
Michael Scholz michael.scholz@th-deg.de
fitMarkovChain
# 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")
cls <- as.clickstreams(clickstreams, 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.