Question: 3 LDA [ 4 5 pts ] The binary LDA classification of x 2 2 was solved by finding the direction of the projection hyperplane

3 LDA [45 pts]
The binary LDA classification of x22 was solved by finding the direction of the projection hyperplane
(wpropSw-1(m2-m1)) in the lecture. In this problem, the binary LDA classification model will be
trained and the train model will generalize the test data. Please display the results for the full credit
consideration.
Generate the data set and split it into train and test sets.
from sklearn import datasets
import numpy as np
X, y = datasets.make_blobs(n_samples =100, n_features =4, centers =2,
cluster_std=1.5, random_state=123)
y =np.array ([-1 if i=0 else 1 for i in y ])
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.2, random_state=42)
a.10pts Write a method that computes the between-class scatter matrix SB. Compute SB using a
train data.
b.[10 pts] Write a method that computes and returns the within-class scatter of each class, the total
within-class scatter (Sw), and its inverse (Sw-1). Calculate Sw and Sw-1 using the train data.
c.10pts NumPy.linalg.eig(*
3 LDA [ 4 5 pts ] The binary LDA classification

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!