CS 10: Problem solving via Object Oriented Programming Pattern Recognition
Agenda 1. Pattern matching vs. recognition 2. From Finite Automata to Hidden Markov Models 3. Decoding: Viterbi algorithm 4. Training 2
Last class we discussed how to use a Finite Automata to match a pattern Email addresses follow a pattern: mailbox@domain.TLD example: tjp@cs.dartmouth.edu com Start . a-z @ a-z edu a-z a-z org Finite Automata can represent email address pattern Sample addresses can be easily verified if in correct form . The email address pattern must be followed exactly . Any deviation results in rejection . 3
Sometimes our input is noisy and does not exactly match a pattern Pattern matching vs. recognition Matching Recognition Is this a duck? 4 Image: duckrace.com
Sometimes our input is noisy and does not exactly match a pattern Pattern matching vs. recognition Matching Recognition Looks like a duck Is this a duck? 5 Image: duckrace.com
Sometimes our input is noisy and does not exactly match a pattern Pattern matching vs. recognition Matching Recognition Looks like a duck Quacks like a duck Is this a duck? 6 Image: duckrace.com
Sometimes our input is noisy and does not exactly match a pattern Pattern matching vs. recognition Matching Recognition Looks like a duck Quacks like a duck Does not wear cool Is this a duck? eyewear 7 Image: duckrace.com
Sometimes our input is noisy and does not exactly match a pattern Pattern matching vs. recognition Matching Recognition Looks like a duck Quacks like a duck Does not wear cool Is this a duck? eyewear Is it a duck? Pattern recognition still accepts this as a duck, even though not all features match 8 Image: duckrace.com
Agenda 1. Pattern matching vs. recognition 2. From Finite Automata to Hidden Markov Models 3. Decoding: Viterbi algorithm 4. Training 9
We can model systems using Finite Automata Weather model: possible states The State of the weather can be: • Sunny Sunny Cloudy • Cloudy • Rainy Rainy 10 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
We can model systems using Finite Automata Weather model: transitions 0.8 0.15 0.5 We can observe weather patterns and 0.2 determine probability Sunny Cloudy of transition between states 0.2 0.2 0.05 0.3 Rainy 0.6 11 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
We can model systems using Finite Automata Weather model: Sunny day example 0.8 0.15 0.5 Probability a sunny day is followed by: 0.2 Sunny Cloudy 0.2 0.2 0.05 0.3 Rainy 0.6 12 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
We can model systems using Finite Automata Weather model: Sunny day example 0.8 0.15 0.5 Probability a sunny day is followed by: 0.2 • Another sunny day 80% Sunny Cloudy 0.2 0.2 0.05 0.3 Rainy 0.6 13 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
We can model systems using Finite Automata Weather model: Sunny day example 0.8 0.15 0.5 Probability a sunny day is followed by: 0.2 • Another sunny day 80% Sunny Cloudy • A cloudy day 15% 0.2 0.2 0.05 0.3 Rainy 0.6 14 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
We can model systems using Finite Automata Weather model: Sunny day example 0.8 0.15 0.5 Probability a sunny day is followed by: 0.2 • Another sunny day 80% Sunny Cloudy • A cloudy day 15% • A rainy day 5% 0.2 0.2 0.05 0.3 Rainy 0.6 15 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
Model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy 0.2 0.2 0.05 0.3 Rainy 0.6 16 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy 0.2 0.2 0.05 0.3 Rainy 0.6 17 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy 0.2 0.2 0.05 0.3 Rainy 0.6 18 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 0.05 0.3 Rainy 0.6 19 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 • Could be cloudy, then rainy 0.05 0.3 Rainy 0.6 20 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 • Could be cloudy, then rainy 0.05 0.3 Rainy 0.6 21 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 • Could be cloudy, then rainy (0.15*0.3) 0.05 0.3 Rainy 0.6 22 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 • Could be cloudy, then rainy (0.15*0.3) 0.05 0.3 • Could be rainy, then rainy Rainy 0.6 23 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 • Could be cloudy, then rainy (0.15*0.3) 0.05 0.3 • Could be rainy, then rainy Rainy 0.6 24 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 • Could be cloudy, then rainy (0.15*0.3) 0.05 0.3 • Could be rainy, then rainy (0.05*0.6) Rainy 0.6 25 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
FA model allows us to answer questions about the probability of events occurring Weather model: predict two days in advance Given today is sunny, 0.8 0.15 0.5 what is the probability it will be rainy two days from now? 0.2 Sunny Cloudy • Could be sunny, then rainy (0.8*0.05) 0.2 0.2 • Could be cloudy, then rainy (0.15*0.3) 0.05 0.3 • Could be rainy, then rainy (0.05*0.6) Rainy Total = (0.8*0.05) 0.6 + (0.15*0.3) + (0.05*0.6) = 0.115 26 Adapted from: https://pdfs.semanticscholar.org/b328/2eb0509442b80760fea5845e158168daee62.pdf
Recommend
More recommend