Linear classification LDA - project line boundary

4 ビュー (過去 30 日間)
Ahmed Mostfa
Ahmed Mostfa 2016 年 3 月 19 日
コメント済み: Swarnima Khadanga 2021 年 4 月 15 日
How can I project the line obtained from linear discriminant analysis. I couldn't find how to make it despite it is easy task. I follow the materials provided online, but no one explain how to project the line and plot the data classes.
% Number of observations of each class
n1=size(c1,1)
n2=size(c2,1)
%Mean of each class
mu1=mean(c1)
mu2=mean(c2)
% Average of the mean of all classes
mu=(mu1+mu2)/2
% Center the data (data-mean)
d1=c1-repmat(mu1,5,1)
d2=c2-repmat(mu2,6,1)
% Calculate the within class variance (SW)
s1=d1'*d1
s2=d2'*d2
sw=s1+s2
invsw=inv(sw)
% in case of two classes only use v-direction of projection
v=invsw*(mu1-mu2)'
% % if more than 2 classes calculate between class variance (SB)
sb1=n1*(mu1-mu)'*(mu1-mu)
sb2=n2*(mu2-mu)'*(mu2-mu)
SB=sb1+sb2
v=invsw*SB
%
% % find eigne values and eigen vectors of the (v)
[evec,eval]=eig(v)
% Sort eigen vectors according to eigen values (descending order) and
% neglect eigen vectors according to small eigen values
% v=evec(greater eigen value)
% or use all the eigen vectors
% project the data of the first and second class respectively
y2=c2*v
y1=c1*v
unique(c1)
  1 件のコメント
Swarnima Khadanga
Swarnima Khadanga 2021 年 4 月 15 日
Have you got the idea how to plt it?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by