44
ยฉ 2012 Boise State University 1 CS-334 Algorithms of Machine Learning Topic: Sequential Modeling Arthur Putnam

CS-334 Algorithms of Machine Learning

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

ยฉ 2012 Boise State University 1

CS-334Algorithms of Machine Learning

Topic: Sequential Modeling

Arthur Putnam

Boise State University 2

Overview

โ€ข Sequential data

โ€ข What we can do with sequential modeling

โ€ข What techniques are out there

โ€ข Introduction into Markov Chains

Boise State University 3

What is Sequential Data?What comes to mind?

Boise State University 4

What is Sequential Data?

Sequential Data is any kind of data where the order โ€œmattersโ€

What makes Sequential Data different from Timeseries data?

Boise State University 5

Why is it important to know if our data is sequential ?When should we consider using a sequential approach?

When โ€œcriticalโ€ information is lost if the order is lost or not represented

Boise State University 6

Does the order of this data matter? Why or why not?Hint: this may be trick question

Key takeaway: just because the data has a sequential element doesnโ€™t mean we should model it that way

Boise State University 7

What we can do with sequential modeling?

โ€ข Classification

โ€ข Predict the next item in the sequence

โ€ข Determine if a given sequence is normal or abnormal

โ€ข Use it to create generative AI

Boise State University 8

Common Ways to Model Sequential Data

โ€ข Conditional Random Fields

โ€ข Recurrent Neural Networks (RNN)

โ€ข Markov Chains

โ€ข HMMs

Boise State University 9

Sequential State Spaces

For the rest of this lecture we are going to assume both time and states are discrete.

Boise State University 10

Sequential State Spaces

โ€ข Define a state space generically as:

โ€ข ๐‘ ๐‘– represents a discrete state

โ€ข ๐‘†๐‘ก๐‘Ž๐‘ก๐‘’ ๐‘ ๐‘๐‘Ž๐‘๐‘’ contains all possible states for seen and unseen sequences

๐‘†๐‘ก๐‘Ž๐‘ก๐‘’ ๐‘ ๐‘๐‘Ž๐‘๐‘’ = ๐•Š = {๐‘ 0, ๐‘ 1โ€ฆ๐‘ ๐‘›}

Boise State University 11

Sequenceโ€ข Letโ€™s define a sequence as

โ€ข t represents a discrete timestep

โ€ข ๐‘‹๐‘ก represents the discrete state at time ๐‘ก

โ€ข ๐‘‹ is an ordered list where each element is in the state space

๐‘‹ = ๐‘‹๐‘ก = ๐‘‹0, ๐‘‹1, ๐‘‹2, โ€ฆ๐‘‹๐‘ก

โˆ€๐‘ก โˆˆ โ„•, ๐‘‹๐‘ก โˆˆ ๐•Š

Boise State University 12

Sequence Example

โ€ข Let ๐•Š = {๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘ }

๐‘‹ = ๐‘‹0, ๐‘‹1, ๐‘‹2, ๐‘‹3๐‘‹ = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘ 

Game 2Game 1 Game 3 Game 4

๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ ๐‘‹3 = ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘ 

Boise State University 13

Sequence Example 2

โ€ข Let ๐•Š = {๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘ }

๐‘‹ = ๐‘‹0, ๐‘‹1๐‘‹ = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘Ÿ๐‘œ๐‘๐‘˜

Game 2Game 1

๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜

Boise State University 14

Letโ€™s assume we are trying to predict the next move our opponent is going to make in a game of

Rock, Paper, Scissors

Game 2Game 1 Game 3

๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ

Boise State University 15

Modeling Sequential Data

โ€ข One way we might model sequential data is via a probabilistic approach where we predict future states based on the present and the past

๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘๐‘Ÿ๐‘’๐‘ ๐‘’๐‘›๐‘ก, ๐‘๐‘Ž๐‘ ๐‘ก)

Boise State University 16

Example Assumptions

โ€ข Letโ€™s assume we already know the probability distribution

โ€ข This probability distribution is based on our opponent's previous moves

๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘๐‘Ÿ๐‘’๐‘ ๐‘’๐‘›๐‘ก, ๐‘๐‘Ž๐‘ ๐‘ก)

Boise State University 17

๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘๐‘Ÿ๐‘’๐‘ ๐‘’๐‘›๐‘ก, ๐‘๐‘Ž๐‘ ๐‘ก)

๐‘ƒ ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜)

Game 2Game 1 Game 3 Game 4

๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ ๐‘‹3 = ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘ 

๐‘ƒ ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜)

๐‘ƒ ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘  ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜)

Boise State University 18

โ€ข Letโ€™s assume

โ€ข What move should we go with?

๐‘ƒ ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜) = 0.3

๐‘ƒ ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜) = 0.3

๐‘ƒ ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘  ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜) = 0.4

๐‘ƒ ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘  ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜) = 0.4

Boise State University 19

Game 4

Opponent

Our Move

Our Prediction

Boise State University 20

First Approach Assessment

โ€ข What are some problems with this approach?

โ€ข How would we calculate the probability distribution, if it wasnโ€™t given to us?

๐‘ƒ ๐‘Ÿ๐‘œ๐‘๐‘˜ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜) = 0.3

๐‘ƒ ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜) = 0.3

๐‘ƒ ๐‘ ๐‘๐‘–๐‘ ๐‘ ๐‘œ๐‘Ÿ๐‘  ๐‘‹2 = ๐‘๐‘Ž๐‘๐‘’๐‘Ÿ, ๐‘‹1 = ๐‘Ÿ๐‘œ๐‘๐‘˜, ๐‘‹0 = ๐‘Ÿ๐‘œ๐‘๐‘˜) = 0.4

๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘‹๐‘ก , ๐‘‹๐‘กโˆ’1, ๐‘‹๐‘กโˆ’2, โ€ฆ ๐‘‹0)

Boise State University 21

Markov Property

โ€ข Markov Property states that the conditional probability distribution of future states of the process depends only on the present state, not on the sequence of events that preceded it.

โ€ข Markov assumption is used to describe a model where the Markov property is assumed to hold

Boise State University 22

Using the Markov Property

๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘๐‘Ÿ๐‘’๐‘ ๐‘’๐‘›๐‘ก, ๐‘๐‘Ž๐‘ ๐‘ก) ๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘๐‘Ÿ๐‘’๐‘ ๐‘’๐‘›๐‘ก)

๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘‹๐‘ก , ๐‘‹๐‘กโˆ’1, ๐‘‹๐‘กโˆ’2, โ€ฆ ๐‘‹0) ๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘‹๐‘ก)

This simplifies the probability function and is more robust at handling differently ordered sequences

Boise State University 23

Markov Chain

โ€ข A Markov chain is a stochastic model describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event.

Markov Model

Some state ๐‘‹๐‘ก

*Conceptual Model

*We will define this model more formally later

Probability (or a set of probabilities for each state)

๐‘ƒ ๐‘“๐‘ข๐‘ก๐‘ข๐‘Ÿ๐‘’ ๐‘‹๐‘ก)

Boise State University 24

Visualization

https://setosa.io/ev/markov-chains/

Boise State University 25

Markov Chainโ€ข Often considered to be โ€œmemory-lessโ€ thanks to the Markov Property

โ€ข Markov Model can take a sequence as input and produceโ€“ the probability of that sequence

โ€“ or the probability of the next states in the sequence

โ€ข Is trained from empirical data โ€“ (multiset of sequences)

โ€ข Pros: easy to train, simple to understand

Boise State University 26

Letโ€™s Build a Markov Chain from Scratchโ€ข We need to:

โ€“ Define the state space

โ€“ Find the initial probabilities

โ€“ Find the transition probabilities

โ€ข Data Setโ€“ Sequences:

โ€ข RRPSSRPSRP

โ€ข PPPSPSPSRR

โ€ข RPSSPSRPSP

โ€“ R = Rock, P = Paper, S = Scissors

Boise State University 27

Define the state space

Empirical data:โ€ข RRPSSRPSRP

โ€ข PPPSPSPSRR

โ€ข RPSSPSRPSP

๐•Š = {๐‘…, ๐‘ƒ, ๐‘†}

Boise State University 28

Find the Initial Probabilities

Empirical data:โ€ข RRPSSRPSRP

โ€ข PPPSPSPSRR

โ€ข RPSSPSRPSP

R starting Probability P starting Probability S starting Probability

2/3 = 0.666 1/3 = 0.333 0/3 = 0

Boise State University 29

Find the Transition Probabilities

Empirical data:โ€ข RRPSSRPSRP

โ€ข PPPSPSPSRR

โ€ข RPSSPSRPSP

State Transitions ๐‘ƒ ๐‘‹๐‘ก+1 ๐‘‹๐‘ก)

RR 2/7

RP

RS

PR

PP

PS

SR

SP

SS

๐‘ƒ ๐‘‹๐‘ก+1 = ๐‘… ๐‘‹๐‘ก = ๐‘…)

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘๐‘Ž๐‘–๐‘Ÿ๐‘  ๐‘คโ„Ž๐‘’๐‘Ÿ๐‘’ ๐‘‹๐‘ก , ๐‘‹๐‘ก+1 ๐‘–๐‘  ๐‘ ๐‘’๐‘’๐‘›

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘‹๐‘ก

Boise State University 30

Find the Transition Probabilities

Empirical data:โ€ข RRPSSRPSRP

โ€ข PPPSPSPSRR

โ€ข RPSSPSRPSP

State Transitions ๐‘ƒ ๐‘‹๐‘ก+1 ๐‘‹๐‘ก)

RR 2/7

RP 5/7

RS

PR

PP

PS

SR

SP

SS

๐‘ƒ ๐‘‹๐‘ก+1 = ๐‘… ๐‘‹๐‘ก = ๐‘ƒ)

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘๐‘Ž๐‘–๐‘Ÿ๐‘  ๐‘คโ„Ž๐‘’๐‘Ÿ๐‘’ ๐‘‹๐‘ก , ๐‘‹๐‘ก+1 ๐‘–๐‘  ๐‘ ๐‘’๐‘’๐‘›

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘‹๐‘ก

Boise State University 31

Find the Transition Probabilities

Empirical data:โ€ข RRPSSRPSRP

โ€ข PPPSPSPSRR

โ€ข RPSSPSRPSP

State Transitions ๐‘ƒ ๐‘‹๐‘ก+1 ๐‘‹๐‘ก)

RR 2/7

RP 5/7

RS 0/7

PR

PP

PS

SR

SP

SS

๐‘ƒ ๐‘‹๐‘ก+1 = ๐‘… ๐‘‹๐‘ก = ๐‘†)

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘๐‘Ž๐‘–๐‘Ÿ๐‘  ๐‘คโ„Ž๐‘’๐‘Ÿ๐‘’ ๐‘‹๐‘ก , ๐‘‹๐‘ก+1 ๐‘–๐‘  ๐‘ ๐‘’๐‘’๐‘›

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘‹๐‘ก

Boise State University 32

Find the Transition Probabilities

Empirical data:โ€ข RRPSSRPSRP

โ€ข PPPSPSPSRR

โ€ข RPSSPSRPSP

State Transitions ๐‘ƒ ๐‘‹๐‘ก+1 ๐‘‹๐‘ก)

RR 2/7 = 0.285

RP 5/7 = 0.714

RS 0/7 = 0

PR 0/10 = 0

PP 2/10 = 0.2

PS 8/10 = 0.8

SR 4/10 = 0.4

SP 4/10 = 0.4

SS 2/10 = 0.2

๐‘ƒ ๐‘‹๐‘ก+1 ๐‘‹๐‘ก)

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘๐‘Ž๐‘–๐‘Ÿ๐‘  ๐‘คโ„Ž๐‘’๐‘Ÿ๐‘’ ๐‘‹๐‘ก , ๐‘‹๐‘ก+1 ๐‘–๐‘  ๐‘ ๐‘’๐‘’๐‘›

๐‘๐‘ข๐‘š๐‘๐‘’๐‘Ÿ ๐‘œ๐‘“ ๐‘‹๐‘ก

Boise State University 33

So now we haveโ€ฆ

R starting Probability P starting Probability S starting Probability

2/3 = 0.666 1/3 = 0.333 0/3 = 0

State Transitions ๐‘ƒ ๐‘‹๐‘ก+1 ๐‘‹๐‘ก)

RR 2/7 = 0.285

RP 5/7 = 0.714

RS 0/7 = 0

PR 0/10 = 0

PP 2/10 = 0.2

PS 8/10 = 0.8

SR 4/10 = 0.4

SP 4/10 = 0.4

SS 2/10 = 0.2

Transition Probabilities Initial Probabilities

Now we should be able to calculate the probability of the sequence of: RPS

Boise State University 34

So now we haveโ€ฆ

R starting Probability P starting Probability S starting Probability

2/3 = 0.666 1/3 = 0.333 0/3 = 0

State Transitions ๐‘ƒ ๐‘‹๐‘ก+1 ๐‘‹๐‘ก)

RR 2/7 = 0.285

RP 5/7 = 0.714

RS 0/7 = 0

PR 0/10 = 0

PP 2/10 = 0.2

PS 8/10 = 0.8

SR 4/10 = 0.4

SP 4/10 = 0.4

SS 2/10 = 0.2

Transition Probabilities Initial Probabilities

calculate the probability of the sequence of: RPS

๐‘ƒ ๐‘‹0 = ๐‘… โˆ— ๐‘ƒ ๐‘‹1 = ๐‘ƒ ๐‘‹0 = ๐‘…) โˆ— ๐‘ƒ(๐‘‹2 = ๐‘† | ๐‘‹1 = ๐‘ƒ)

2

3โˆ—5

7โˆ—8

10=

80

210=

8

21โ‰ˆ 0.38

Boise State University 35

Looking up each probability is still tediousโ€ข Lucky we can redefine this process as a series of matrix multiplications

โ€ข We can also define 1xN (denoted by ฯ€) vector to represent our initial state probabilities

โ€ข We can define a NxN matrix (denoted by P) which represents the transition probabilities

โ€ข From there we can use

๐‘ƒ ๐‘ ๐‘’๐‘ž๐‘ข๐‘’๐‘›๐‘๐‘’ = ๐œ‹๐‘ ๐‘ก๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘›๐‘”_๐‘ ๐‘ก๐‘Ž๐‘ก๐‘’ โˆ— ๐‘ƒ๐‘ก๐‘Ÿ๐‘Ž๐‘›๐‘ ๐‘–๐‘ก๐‘–๐‘œ๐‘›1 โˆ— ๐‘ƒ๐‘ก๐‘Ÿ๐‘Ž๐‘›๐‘ ๐‘–๐‘ก๐‘–๐‘œ๐‘›2 โ€ฆโˆ— ๐‘ƒ๐‘ก๐‘Ÿ๐‘Ž๐‘›๐‘ ๐‘–๐‘ก๐‘–๐‘œ๐‘›_๐‘›

Boise State University 36

Initial State Probabilities

โ€ข We can also define 1xN (denoted by ฯ€) vector to represent our initial state probabilities

๐œ‹ = ๐‘๐•Š๐‘–๐‘›๐‘–๐‘ก๐‘Ž๐‘™1 , ๐‘๐•Š๐‘–๐‘›๐‘–๐‘ก๐‘Ž๐‘™2 , โ€ฆ ๐‘๐•Š๐‘–๐‘›๐‘–๐‘ก๐‘Ž๐‘™๐‘›

๐œ‹ = 0.666, 0.333, 0

๐•Š = {๐‘…, ๐‘ƒ, ๐‘†}

Boise State University 37

Transition Matrix

โ€ข Let p be an NxN matrix where N is the number of discrete states

P=

๐‘11 ๐‘12 โ‹ฏ ๐‘1๐‘›๐‘21 ๐‘22 โ€ฆ ๐‘2๐‘›โ‹ฎ

๐‘๐‘›1

โ‹ฎ๐‘๐‘›2

โ‹ฑ โ‹ฎโ€ฆ ๐‘๐‘›๐‘›

๐‘ƒ๐‘–๐‘— = ๐‘ƒ(๐•Š๐‘—|๐•Š๐‘–)

*Assume ๐•Š is ordered

P =0.285 0.714 00 0.2 0.80.4 0.4 0.2

R P S

RPS

๐•Š = {๐‘…, ๐‘ƒ, ๐‘†}

๐‘ƒ๐‘–๐‘— = ๐‘ƒ(๐•Š๐‘—|๐•Š๐‘–)

Boise State University 38

Markov Chain

โ€ข We can now calculate the probability of a sequence by โ€œchainingโ€ together the elements of the matrix

๐‘ƒ ๐‘ ๐‘’๐‘ž๐‘ข๐‘’๐‘›๐‘๐‘’ = ๐œ‹๐‘ ๐‘ก๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘›๐‘”_๐‘ ๐‘ก๐‘Ž๐‘ก๐‘’ โˆ— ๐‘ƒ๐‘ก๐‘Ÿ๐‘Ž๐‘›๐‘ ๐‘–๐‘ก๐‘–๐‘œ๐‘›1 โˆ— ๐‘ƒ๐‘ก๐‘Ÿ๐‘Ž๐‘›๐‘ ๐‘–๐‘ก๐‘–๐‘œ๐‘›2 โ€ฆโˆ— ๐‘ƒ๐‘ก๐‘Ÿ๐‘Ž๐‘›๐‘ ๐‘–๐‘ก๐‘–๐‘œ๐‘›_๐‘›

Boise State University 39

Letโ€™s check

Previously we calculated the probability of the sequence of: RPS using the โ€œoldโ€ method. Letโ€™s try the matrix method.

๐‘ƒ ๐‘‹0 = ๐‘… โˆ— ๐‘ƒ ๐‘‹0 = ๐‘ƒ ๐‘‹0 = ๐‘…) โˆ— ๐‘ƒ(๐‘‹1 = ๐‘† | ๐‘‹1 = ๐‘ƒ)

2

3โˆ—5

7โˆ—8

10=

8

21โ‰ˆ 0.38

๐œ‹1 โˆ— ๐‘ƒ12 โˆ— ๐‘ƒ230.666 โˆ— 0.714 โˆ— 0.8 = 0.38

Boise State University 40

Your Turn! Class Challenge

โ€ข Assume ๐•Š = {๐‘†, ๐‘ƒ, ๐‘…}

โ€ข Assume ๐œ‹ = 0.8, 0.1, 0.1

โ€ข Create the Transition matrix P

โ€ข Try to find the probability for:

โ€“ SPR

Boise State University 41

Your Turn! Class Challenge

โ€ข Assume ๐•Š = {๐‘†, ๐‘ƒ, ๐‘…}

โ€ข Assume ๐œ‹ = 0.8, 0.1, 0.1

โ€ข Try to find the probability for:

โ€“ SPR

https://setosa.io/ev/markov-chains/

๐‘ƒ =0.5 0.4 0.10.4 0.5 0.10.2 0.2 0.6

๐œ‹1 โˆ— ๐‘12 โˆ— ๐‘23 = 0.8 โˆ— 0.4 โˆ— 0.1 = 0.032

Boise State University 42

So what can we do with our Markov chain

โ€ข Calculate the probability of a sequence

โ€“ This is useful for comparing on sequence to another

โ€“ We could also use this to classify by pick a probability cutoff point

โ€ข We can calculate the probability of ending in state S after some number of transitions T

Boise State University 43

Recommended Next Steps

โ€ข Hidden Markov Models (HMM)

โ€“ We are making the assumptions that are likely untrue, HMMs help address or model hidden states

โ€ข Smoothing & Normalization

โ€“ Some transitions might never happen in our data set, thus the probability will be zero which is probably not what we want

Boise State University 44

THANK YOU

Arthur Putnam

Email: [email protected]