Page 1 of 1

H2.2 Perceptron learning algorithm (PLA) and kernel extension: In this problem you will implement PLA to build a simple

Posted: Mon May 02, 2022 11:38 am
by answerhappygod
H2 2 Perceptron Learning Algorithm Pla And Kernel Extension In This Problem You Will Implement Pla To Build A Simple 1
H2 2 Perceptron Learning Algorithm Pla And Kernel Extension In This Problem You Will Implement Pla To Build A Simple 1 (117.76 KiB) Viewed 25 times
H2.2 Perceptron learning algorithm (PLA) and kernel extension: In this problem you will implement PLA to build a simple binary classification system. Suppose we have labeled data (Xi, Yi), where x; € Rd+1 with xi(1) = 1 and y E{-1, +1}. Let us define hw(xi) sign(w+x;). We want to compute w using PLA. (50 pts) = (a) Data Processing: Generate two examples of 2D linearly separable dataset with N = 100 samples each. (To do this, you will first generate a weight vector and constant term, w, and then assign +1 labels to your data samples as yi = hw(xi).) Let us call the two datasets “Datal” and "Data2”. For Datal, randomly select 80% of the samples for training and the remaining 20% for testing on Datal (80/20). For Data2, randomly select 30% of the samples for training and the remaining 70% for testing (30/70). (b) Implementation: Write a script for PLA in Python by initializing w= 0 and using the following update rule: for i=1,...,N 1 W = W+ 2 (Y (Yi – hw(Xi))xi.
(c) Training: Use your PLA implementation to train two linear classifiers for Datal and Data2 using the respective training samples. Plot the training samples, test samples, and separation lines for both examples in two separate plots. (d) Testing: Using the test samples in each example, compute precision, recall, and fl-score for your classifiers. tp Precision is defined as -; tp and fp denote the number of true and false positives. tp + fp tp Recall is defined as ; fn denotes the number of false negatives. tp + fn precision x recall f1-score is defined as 2 ; it can be viewed as a measure of accuracy and ranges precision +recall between 0 (worst) and 1 (best). (e) Kernel perceptron: Note that we can define the weight vector as w=D1 QiY;X;. We can view this as the dual perceptron in which we initialize di = 0 for i = 1, ..., N and update them as follows. = for j=1, ,...,N N (x2) û = sign (qiyix?x; if û + Yj, update a; = a; +1 Implement the kernel perceptron and demonstrate that the classifier you learn is identical to the one in step (b).