Introduction to LDA (Linear Discrimination Analysis)

Linear Discrimination Analysis

锻炼一下ability of english writing : ) 光看不写感觉不行哇~

First of all, we try to solve a problem and then guide the LDA out here :)

Here is the question that there are two different points in this picture, what‘s the evidence in mathmatic that  you classify there two different points.

After classification, try to input some generic points and classify these inputed points by that mathmatic evidence that you have found.

--------------------------------------------------------------------------------------------------------------------------------------

Method One:  the distance between projected means

Just compute the different mean value of different class points. Compare the distance between the inputed new points and the mean value‘s location. If the inputed points is close to mean value location of RED class,
we treat its as red class, verse via.

The green point in this picture is the mean location of blue class.

The yellow point in this picture is the mean location of red  class.

Which points close to the mean point of which class, it belongs to that class.

However, the distance between projected means is not a good measure  since it does not account for the standard deviation within classes

Method two : Fisher’s linear discriminant

This is a fantastic discriminant method  \(^o^)/~

What is our target if we want to descrininate different class datas ?

Fisher suggested
maximizing the difference between the means,  normalized by a measure of the within-class scatter

Attention! y is a vector but not a normal single dimention varible !

So one of our target is to make the within-class scatter as min as possible.

On the another hand, we should consider about the relationship between the two different class of datas.

If could find a matrix W_t which multiple vector x could translate vectorx
into scale y , our will finish half of our work.

Function J(w) is very helpful. It describe the target of our discriminant. The more bigger of J(w), the better of our discriminant

Within-class scatter

Matrix Si describe the level of scatter inner of class-i

Beblow this is a description about within-class scatter in scale y

To get matrix Sw, we could sum all matrix-Si.

Between-class scatter

This Matrix describe the level of scatter between different class.

Everything is more and more clearly...

At this moment, we may memory back the operation of differential on matrix.

After this, you will have the ability to understand proof beblow here.

Attention! SB  is  a diagonal
matrix.  A_t == A

Let‘s have a exercise :)

Go back and consider about there data points in below picture.

First of all we should set the data.

Class_1 = [ 4,1;
            2,4;
            2,3;
            3,6;
            4,4];

Class_2 = [9,10;
    6,8;
    9,5;
    8,7;
    10,8];

And the compute the mean location of each class data collection.

mean_Class_1 = [mean(Class_1(:,1)),mean(Class_1(:,2))];
mean_Class_2 = [mean(Class_2(:,1)),mean(Class_2(:,2))];

mean_Class_1 =

3.0000    3.6000

mean_Class_2 =

8.4000    7.6000

And then compute S1 and S2

S_w =

13.2000   -2.2000

-2.2000   26.4000

S_b =

29.1600   21.6000

21.6000   16.0000

S_w = S_1 + S_2;

S_b = (mean_Class_1 - mean_Class_2)' * (mean_Class_1 - mean_Class_2);

Look! The red line is what we want! Just project every points onto the red line in the picture.

(y - original_y)/(x - original_x) = -1/slope;

new_location_x = ((1/slope)*x_original_point + y_original_point)/(slope + 1/slope);

new_location_y = slope*new_location_x;

Now,I will give my code in matlab which draw that picture out here.

clear all
close all
clc

Class_1 = [ 4,1;
            2,4;
            2,3;
            3,6;
            4,4];

Class_2 = [9,10;
    6,8;
    9,5;
    8,7;
    10,8];

figure(1);
hold on;
scatter(Class_1(:,1),Class_1(:,2),'fill','r');
scatter(Class_2(:,1),Class_2(:,2),'fill','b');

mean_Class_1 = [mean(Class_1(:,1)),mean(Class_1(:,2))];
mean_Class_2 = [mean(Class_2(:,1)),mean(Class_2(:,2))];

scatter(mean_Class_1(1,1),mean_Class_1(1,2),'fill','y');
scatter(mean_Class_2(1,1),mean_Class_2(1,2),'fill','g');

value = Class_1;

S_1 = [0 0;0 0];

for temp = 1:size(Class_1,1)
    value(temp,1) = Class_1(temp,1) - mean_Class_1(1,1);
    value(temp,2) = Class_1(temp,2) - mean_Class_1(1,2);

    S_1 = S_1 + value(temp,:)'*value(temp,:);
end

S_2 = [0 0;0 0];

for temp = 1:size(Class_1,1)
    value(temp,1) = Class_2(temp,1) - mean_Class_2(1,1);
    value(temp,2) = Class_2(temp,2) - mean_Class_2(1,2);

    S_2 = S_2 + value(temp,:)'*value(temp,:);
end

S_w = S_1 + S_2;

S_b = (mean_Class_1 - mean_Class_2)' * (mean_Class_1 - mean_Class_2);

Temp_matrix = inv(S_w)*S_b;

%% compute the eig dialog matrix by function eig()
[V,D] = eig(Temp_matrix);

eig_value = max(D(:));

Temp_matrix(1,1) = Temp_matrix(1,1) - eig_value;
Temp_matrix(2,2) = Temp_matrix(2,2) - eig_value;

slope = -Temp_matrix(1,1)./Temp_matrix(1,2);

x = [1:16];
y = slope*x;

plot(x,y);

Projection_Class_1(:,1) = ...
(Class_1(:,1).*(1/slope) + Class_1(:,2))./(slope + (1/slope));

Projection_Class_1(:,2) = Projection_Class_1(:,1).*slope;

scatter(Projection_Class_1(:,1),Projection_Class_1(:,2),'r');

Projection_Class_2(:,1) = ...
(Class_2(:,1).*(1/slope) + Class_2(:,2))./(slope + (1/slope));

Projection_Class_2(:,2) = Projection_Class_2(:,1).*slope;

scatter(Projection_Class_2(:,1),Projection_Class_2(:,2),'b');
时间: 2024-11-15 00:59:01

Introduction to LDA (Linear Discrimination Analysis)的相关文章

LDA (Linear Discriminant Analysis) 线性判别分析

[1] http://blog.csdn.net/ffeng271/article/details/7353834

线性判别分析(Linear Discriminant Analysis, LDA)算法初识

LDA算法入门 一. LDA算法概述: 线性判别式分析(Linear Discriminant Analysis, LDA),也叫做Fisher线性判别(Fisher Linear Discriminant ,FLD),是模式识别的经典算法,它是在1996年由Belhumeur引入模式识别和人工智能领域的.性鉴别分析的基本思想是将高维的模式样本投影到最佳鉴别矢量空间,以达到抽取分类信息和压缩特征空间维数的效果,投影后保证模式样本在新的子空间有最大的类间距离和最小的类内距离,即模式在该空间中有最佳

线性判别分析(Linear Discriminant Analysis,LDA)

一.LDA的基本思想 线性判别式分析(Linear Discriminant Analysis, LDA),也叫做Fisher线性判别(Fisher Linear Discriminant ,FLD),是模式识别的经典算法,它是在1996年由Belhumeur引入模式识别和人工智能领域的.线性鉴别分析的基本思想是将高维的模式样本投影到最佳鉴别矢量空间,以达到抽取分类信息和压缩特征空间维数的效果,投影后保证模式样本在新的子空间有最大的类间距离和最小的类内距离,即模式在该空间中有最佳的可分离性. 如

线性判别分析(Linear Discriminant Analysis, LDA)算法分析

LDA算法入门 一. LDA算法概述: 线性判别式分析(Linear Discriminant Analysis, LDA),也叫做Fisher线性判别(Fisher Linear Discriminant ,FLD),是模式识别的经典算法,它是在1996年由Belhumeur引入模式识别和人工智能领域的.性鉴别分析的基本思想是将高维的模式样本投影到最佳鉴别矢量空间,以达到抽取分类信息和压缩特征空间维数的效果,投影后保证模式样本在新的子空间有最大的类间距离和最小的类内距离,即模式在该空间中有最佳

【转载】线性判别分析(Linear Discriminant Analysis)(一)

线性判别分析(Linear Discriminant Analysis)(一) 1. 问题 之前我们讨论的PCA.ICA也好,对样本数据来言,可以是没有类别标签y的.回想我们做回归时,如果特征太多,那么会产生不相关特征引入.过度拟合等问题.我们可以使用PCA来降维,但PCA没有将类别标签考虑进去,属于无监督的. 比如回到上次提出的文档中含有“learn”和“study”的问题,使用PCA后,也许可以将这两个特征合并为一个,降了维度.但假设我们的类别标签y是判断这篇文章的topic是不是有关学习方

【转载】线性判别分析(Linear Discriminant Analysis)(二)

线性判别分析(Linear Discriminant Analysis)(二) 4. 实例 将3维空间上的球体样本点投影到二维上,W1相比W2能够获得更好的分离效果. PCA与LDA的降维对比: PCA选择样本点投影具有最大方差的方向,LDA选择分类性能最好的方向. LDA既然叫做线性判别分析,应该具有一定的预测功能,比如新来一个样例x,如何确定其类别? 拿二值分来来说,我们可以将其投影到直线上,得到y,然后看看y是否在超过某个阈值y0,超过是某一类,否则是另一类.而怎么寻找这个y0呢? 看 根

线性判别分析(Linear Discriminant Analysis)

线性判别分析(Linear Discriminant Analysis) 标签(空格分隔): 监督学习 @author : [email protected] @time : 2016-07-11 线性判别分析Linear Discriminant Analysis 线性分类器 判别式函数discriminant functions 从判别式或后验概率到决策面 线性判别分析Linear Discriminant Analysis 二次判别分析QDA Fisher判别式 类间距离 类内距离 Fis

OpenCV LDA(Linnear Discriminant analysis)类的使用---OpenCV LDA示例

1.OpenCV中LDA类的声明 //contrib.hpp class CV_EXPORTS LDA { public: // Initializes a LDA with num_components (default 0) and specifies how // samples are aligned (default dataAsRow=true). LDA(int num_components = 0) : _num_components(num_components) {}; //

【CV论文阅读】Deep Linear Discriminative Analysis, ICLR, 2016

DeepLDA 并不是把LDA模型整合到了Deep Network,而是利用LDA来指导模型的训练.从实验结果来看,使用DeepLDA模型最后投影的特征也是很discriminative 的,但是很遗憾没有看到论文是否验证了topmost 的hidden representation 是否也和softmax指导产生的representation一样的discriminative. DeepLDA和一般的deep network唯一不同是它的loss function.两者对比如下: 对于LDA,