Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

PST (version 0.81)

pmine: PST based pattern mining

Description

Mine for (sub)sequences in a state sequence object satisfying user defined criteria

Usage

## S3 method for class 'PSTf,stslist':
pmine(object, data, l, pmin, pmax, lag, state, average=FALSE, output="sequences")

Arguments

object
A fitted PST, that is an object of class PSTf as returned by the pstree or prune method.
data
a sequence object of class 'stslist' as defined with the seqdef function of the TraMineR library.
l
length of the subsequence to search for.
pmin
numeric. Minimal probability for selecting the (sub)sequence.
pmax
numeric. Maximal probability for selecting the (sub)sequence.
lag
integer. The lag first states in the sequence are omitted.
state
average
logical. If TRUE, the pmin or pmax probability is supposed to be the average state probability in the (sub)sequences. If FALSE (sub)sequences having every state probability less than pmax or
output
character. If output='sequences' the whole sequence(s) where the user defined criteria is satisfied are returned. If output='patterns' only the (sub)sequences satisfying the user defined criteria are returned.

Value

  • A state sequence object, that is an object of class stslist

Details

The likelihood $P^{S}(x)$ of a whole sequence $x$ is computed from the state probabilities at each position in the sequence. However, the likelihood of the first states is usually lower than at higher position due to a reduced memory available for prediction. A sequence may not appear as very likely if its first state has a low relative frequency, even if the model predicts high probabilities for the states at higher positions.

The pmine function allows for advanced pattern mining with user defined parameters. It is controlled by the lag and pmin arguments. For example, by setting lag=2 and pmin=0.40 (example 1), we select all sequences with average (the geometric mean is used) state probability from position $lag+1, \ldots, \ell$ above pmin. Instead of considering the average state probability at positions $lag+1, \ldots, \ell$, it is also possible to select frequent patterns that do not contain any state with probability below the threshold. This prevents from selecting sequences having many states with high probability but one ore several states with a low probability.

It is also possible to mine the sequence data for frequent patterns of length $\ell_{j} < \ell$, regardless of the position in the sequence where they occur. By using the output="patterns" argument, the pmine function returns the patterns (as a sequence object) instead of the whole set of distinct sequences containing the patterns. Since the probability of a pattern can be different depending on the context (previous states) the returned subsequences also contain the context preceding the pattern.

See Also

cmine for context mining

Examples

Run this code
## activity calendar for year 2000
## from the Swiss Household Panel
## see ?actcal
data(actcal)

## selecting individuals aged 20 to 59
actcal <- actcal[actcal$age00>=20 & actcal$age00 <60,]

## defining a sequence object
actcal.lab <- c("> 37 hours", "19-36 hours", "1-18 hours", "no work")
actcal.seq <- seqdef(actcal,13:24,labels=actcal.lab)

## building a PST
actcal.pst <- pstree(actcal.seq, nmin=2, ymin=0.001)

## pruning
## Cut-offs for 5% and 1% (see ?prune)
C99 <- qchisq(0.99,4-1)/2
actcal.pst.C99 <- prune(actcal.pst, gain="G2", C=C99)

## example 1
pmine(actcal.pst.C99, actcal.seq, pmin=0.4, lag=2)

## example 2: patterns of length 6 having p>=0.6
pmine(actcal.pst.C99, actcal.seq, pmin=0.6, l=6)

Run the code above in your browser using DataLab