0% found this document useful (0 votes)
15 views5 pages

Week 5 & 6 - Practice Exercise - ML

Uploaded by

Rishi Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

Week 5 & 6 - Practice Exercise - ML

Uploaded by

Rishi Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Week 5 & Week 6 – Exercise

1. Principal Component Analysis (PCA)


An e-commerce company that collects data on customer behavior. The company has
gathered data on 1,000 customers across the following variables:

1. Annual Income (in $)


2. Spending Score (a value from 1 to 10 based on customer spending habits)
3. Age (in years)
4. Number of Website Visits in the last month
5. Number of Purchases in the last year

The marketing team wants to identify key patterns in customer behavior to create targeted
marketing strategies, but the large number of variables makes it difficult to visualize and
interpret the data directly. They want you to reduce the dimensionality of the data while
retaining as much variance (information) as possible.

You have to perform:


 Perform PCA on the customer data to reduce the 5 variables into 2 principal
components.
 Explain how much variance is captured by each of the first two principal
components.
 Based on the results, discuss how these principal components could help the
marketing team better understand customer behavior.
 Plot the customers on a 2D graph using the first two principal components, and
suggest any potential customer clusters that the marketing team might target.
 You need to use Orthogonal graph for predicting.
2. Hidden Markov Model (HMM)

You are trying to predict the weather based on past data, where the possible weather states are
Sunny, Cloudy, and Rainy.

Predicted weather sequence for the next 4 days: ['Sunny', 'Sunny', 'Cloudy', 'Cloudy']
3. Forward and Backward Algorithms for an HMM

Predicts the probability of carrying an umbrella based on the current weather. The
weather can be Sunny, Cloudy, or Rainy, but you can only observe whether a person
is carrying an umbrella or not. The goal is to calculate the probabilities of the hidden
states (the weather) given the observations using the Forward and Backward
algorithms.

This means the probability of starting in the Sunny state is 0.5, Cloudy state is 0.3,
and Rainy state is 0.2.

Observation Sequence:

You have to observe the following sequence: (Umbrella, No Umbrella, Umbrella)

List of Task you have to show in Python code implementation

1. Implement the Forward Algorithm to calculate the probability of observing the


sequence (Umbrella, No Umbrella, Umbrella).
2. Implement the Backward Algorithm to calculate the backward probabilities for
the same sequence.
3. Compute the overall probability of the observation sequence using both
algorithms.

4. Viterbi algorithm

Speech recognition using Viterbi algorithm in machine learning.

a speech recognition system that attempts to recognize a spoken sentence. The system picks up
audio signals but often makes mistakes due to noise in the input. You want to use the Viterbi
algorithm to decode the most likely original sequence of words that were spoken based on the
noisy observed sequence.

You have the following information:

1. States (hidden): Word 1, Word 2, Word 3, ... (the actual words that might have been
spoken).

2. Observations: Phoneme 1, Phoneme 2, Phoneme 3, ... (the sounds recognized by the


system, which are noisy).

3. Observation Sequence: A sequence of phonemes that the system has recognized, such as
Phoneme 1, Phoneme 2, Phoneme 3.

Your task is to find the most likely sequence of words that corresponds to the observed sequence
of phonemes.

Given:

1. States (hidden words): Word A, Word B, Word C.

2. Observations (recognized phonemes): Phoneme X, Phoneme Y, Phoneme Z.

3. Observation Sequence: A sequence of phonemes, for example, Phoneme X, Phoneme Y,


Phoneme X.

Probabilities:

1. Initial Probabilities (starting words):

 P(Word A) = 0.4

 P(Word B) = 0.4

 P(Word C) = 0.2

2. Transition Probabilities (between words):

 P(Word A → Word A) = 0.5, P(Word A → Word B) = 0.3, P(Word A → Word C) = 0.2

 P(Word B → Word A) = 0.2, P(Word B → Word B) = 0.6, P(Word B → Word C) = 0.2

 P(Word C → Word A) = 0.3, P(Word C → Word B) = 0.2, P(Word C → Word C) = 0.5


3. Observation Probabilities (likelihood of observing a phoneme given a word):

 For Word A: P(Phoneme X) = 0.6, P(Phoneme Y) = 0.3, P(Phoneme Z) = 0.1

 For Word B: P(Phoneme X) = 0.2, P(Phoneme Y) = 0.5, P(Phoneme Z) = 0.3

 For Word C: P(Phoneme X) = 0.1, P(Phoneme Y) = 0.4, P(Phoneme Z) = 0.5

Task:

Assume the system recognized the following sequence of phonemes: Phoneme X, Phoneme Y,
Phoneme X. Find the probability of this most likely sequence of words that produced this
observation using the Viterbi algorithm.

You might also like