0% found this document useful (0 votes)
42 views3 pages

Batch15 Individual Assignment - MLSL2

This document provides instructions for four hands-on ML assignments: 1. Visualizing pairwise Fisher discriminant analysis on digit classification data to see how features discriminate between pairs of classes. 2. Building 1-vs-rest SVM classifiers on letter recognition data for varying kernels and hyperparameters, and commenting on results. 3. Building pairwise SVM classifiers on letter recognition data and commenting on most/least similar class pairs. 4. Developing a local linear regression model on Mexican hat wave data using a binary search tree approach, with functions to train the model recursively and predict values using the trained model structure.

Uploaded by

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

Batch15 Individual Assignment - MLSL2

This document provides instructions for four hands-on ML assignments: 1. Visualizing pairwise Fisher discriminant analysis on digit classification data to see how features discriminate between pairs of classes. 2. Building 1-vs-rest SVM classifiers on letter recognition data for varying kernels and hyperparameters, and commenting on results. 3. Building pairwise SVM classifiers on letter recognition data and commenting on most/least similar class pairs. 4. Developing a local linear regression model on Mexican hat wave data using a binary search tree approach, with functions to train the model recursively and predict values using the trained model structure.

Uploaded by

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

MLSL2 Hands-on Assignment

Instructions:
- There are four questions
- Each question carries 25 points.

1. Visualizing Pairwise Fisher Discriminant


- Dataset: https://www.kaggle.com/c/digit-recognizer
- For every pair of classes (0, 1), (0, 9), …, (8, 9)
- Compute the Fisher Discriminant of each pixel (feature)
o Note that some of the pixels might have a zero denominator
o Treat that as 0 Fisher
- Normalize the remaining Fisher discriminant values from 0 to 1
- Draw the Fisher images of each of the pairs of classes
- See how they make sense (e.g. Class (0, 1), (3, 5), (4, 6)).
- This is “feature wise” Fisher goodness of each dimension

2. Support Vector Machines – 1 vs Rest


- Dataset: https://www.kaggle.com/nishan192/letterrecognition-using-svm
- Sample 70% training and 30% test data from each class.
- Write an SVM classifier to build a 1-vs-rest classifier for each class.
- Populate the following table (Test Accuracy)
- Comment on what’s going on as C increases for Linear models
- Comment on what’s going on as Kernel goes from
o Linear, Polynomial, and RBF for C = 5

Target Linear Linear Linear Polynomial Polynomial RBF


Class (C = 1) (C = 5) (C = 10) (d = 2, C = 5) (d = 3, C = 5) (C = 5)
A
B

3. Support Vector Machines – Pair-wise Classifier


- Dataset: https://www.kaggle.com/nishan192/letterrecognition-using-svm
- Sample 70% training and 30% test data from each class.
- Write an SVM classifier to build a pair-wise classifier for each class.
- Populate the following table (Test Accuracy) – Linear (C = 5)
- Comment on which pair of classes are most similar and which are most different.

Positive Class Negative Class Linear


(C = 5)
A B
A C

Y Z

4. Local Linear Regression


- Binary Search: In Computer science when we have to search for an element in a “sorted” list
we use binary search (https://en.wikipedia.org/wiki/Binary_search_tree)
- We will use a similar approach to develop a local-linear embedding in 1-D data
o We will first take the full dataset and learn a “linear regression” model on it
o Then we will divide the data into two parts – left and right and learn a linear
regression on each part and continue till each “leaf node” of the tree gives us an
RMSE below a threshold (specified by the user).
o The trick is in finding the right place to divide the range into two parts.
- Example:
o Let’s say the x axis is between -10 to 10.
o Let’s say we have generated 20000 data points in this range at equal intervals
o We can now try to divide this from [-10, a] and [a, 10]
o We can run a for loop over all possible a values from say -10 to +10
o For each value of a, we learn a linear regression
 for the left part [-10, a] and right part [a, 10]
o Let n(left|a) and n(right|a) be the number of data points in the two parts
o Let rmse(left|a) and rmse(right|a) be the rmse of the two parts
o Then rmse(a) = n(left|a) * rmse(left|a) + n(right|a) * rmse(right|a)
o We find the value of a that gives the best partition of [-10, 10] (min rmse(a)) say A.
o We store the two linear regression models for [-10, A] and [A, 10]
o Now we repeat the same exercise for each of the partitions to grow this further
o If rmse([-10, A]) is < rmse_threshold then
 we stop growing otherwise we call LLE(…, -10, A) again with this range.
o If rmse(A, 10) < rmse_threshold then
 We stop growing otherwise we call LLE(… A, 10) again with this range.

- Dataset: We will learn the local linear embedding for the following function:
o https://en.wikipedia.org/wiki/Ricker_wavelet
- The code to generate this data is given here:
o http://www.southampton.ac.uk/~fangohr/training/python/snippets/lecture09/mex
hat-numpy.py
- Generate this data once and plot it y against x and see if you get the same curve.

- [11 points] Write a function to train such a local linear regression model recursively
o [best_model, best_partition] = LLE(xy_dataset, min_x, max_x, rmse_threshold)
o Store this model so you now where it is in the tree structure
o rmse_threshold determines how deep you go – it’s a hyper-parameter
-
- Note: Ultimately you don’t need all intermediate models, you just need final models:
o Min_x and Max_x value for each model
o Linear coefficients for each model
- When we get a new data point, we first check which model it should go to based on its x
value (and the Min_x, Max_x of each model) and then estimate the y value based on the
selected linear model.

- [6 points] Write a function to predict the y value for a given input using the above structure.

- [8 points] Play with it to see how rmse_threshold affects the “number of linear models” you
get.

You might also like