Python代写｜ECS708 Machine Learning Assignment 2: Clustering and MoG

• ALL

Aim

The aim of this assignment is to become familiar with clustering using the Mixture of Gaussians model.

1 Introduction

For this lab, we will use the Peterson and Barney’s dataset of vowel formant frequencies. (For more info,

More specifically, Peterson and Barney measured the fundamental frequency F0 and the first three formant
frequencies (F1 − F3) of sustained English Vowels, using samples from various speakers.

The dataset can be found in the QMplus, in the files of Assignment 2, in the folder named “data”, at the file
“PB data.npy”. Load the file. In your workspace, you will have 4 vectors (F0 − F3), containing the funda
mental frequencies (F0, F1, F2 and F3) for each phoneme and another vector “phoneme id” containing a
number representing the id of the phoneme. The arrangement of the data is as follows:

In the exercises that follow, we will use only the dataset associated with formants F1 and F2.

2 MoG Modelling using the EM Algorithm

Recall the following definition of a Mixture of Gaussians. Assuming our observed random vector is x, a MoG
models p(x) as a sum of weighted Gaussians. More specifically:

Where D is the dimension of vector x ∈ RD, µk, Σk and p(ck) are the mean vector, covariance matrix, and
the weight of the k-th gaussian component, and K is the total number of gaussian components used.

Load the dataset to your workspace. We will only use the dataset for F1 and F2, arranged into a 2D matrix
where the first column will be F1 and the second column will be F2. Produce a plot of F1 against F2. (You
should be able to spot some clusters already in this scatter plot.).

Include in your report the corresponding lines of your code and the plot. [20 points]

Train the data for phonemes 1 and 2 with MoGs. You are provided with python files task 2.py and plot gaussians.py.
Specifically, you are required to:

1. Look at the task 2.py code and understand what it is calculating. Pay particular attention to the initiali
sation of the means and covariances (also note that it is only estimating diagonal covariances).

2. Generate a dataset X phoneme 1 that contains only the F1 and F2 for the first phoneme.

3. Run task 2.py on the dataset using K=3 Gaussians (run the code a number of times and note the
differences.) Save your MoG model: this should comprise the variables mu, s and p.

4. Run task 2.py on the dataset using K=6

5. Repeat steps 2-4 for the second phoneme

Include in your report the lines of code you wrote, and results that illustrate the learnt models. [20 points]

E-mail: vipdue@outlook.com  微信号:vipnxx