Sequence Prediction using Conditional Probability with Bayes rule

156 Views Asked by At

Let's assume we have four sequences in a dataset: $$A \rightarrow B$$ $$A \rightarrow G \rightarrow M$$ $$R \rightarrow G$$ $$B \rightarrow C \rightarrow G \rightarrow M$$

Now, we have a new sub-sequence and we want to predict the next items in the sequence based on the prior four sequences. Given that we saw the item $A$, I want to calculate the probability to see the sub-sequence $G\rightarrow M$ next. How should I use Bayes rule in order to calculate this probability?

I thought to use it this way: $$P(G\rightarrow M|A)=\frac{P(G\rightarrow M)*P(A|G\rightarrow M)}{P(A)}= \frac{\frac{2}{4}*\frac{1}{2}}{\frac{2}{4}}=\frac{1}{2}$$

Explanation:

$P(G\rightarrow M)=\frac{2}{4}$ - $G\rightarrow M$ appears in two sequences out of four sequences in the dataset.

$P(A)=\frac{2}{4}$ - A appears in two sequences out of four sequences in the dataset.

$P(A|G)=\frac{1}{2}$ - Out of two appearances of $G\rightarrow M$, we have only one sub-sequences of $A \rightarrow G \rightarrow M$ in the dataset.

Is that make sense? Thank you!

1

There are 1 best solutions below

0
On

this is a comment, not an answer .... wanted to added graphics to discuss the problem


below is a "state machine" drawing ... enter image description here