matlab - Plotting the hyperplane of LDA (ClassificationDiscriminant) -


i trying compare various classifiers on data, such lda , svm etc, visually investigate separation hyperplane.

currently using classificationdiscriminant lda classifier, unlike svm can draw hyperplane on graph, not find way plot hyperplane of lda classifier.

the following script how produce sample data , been classified using classificationdiscriminant:

%% data & label x = [randn(100,2); randn(150,2) + 1.5]; y = [zeros(100,1); ones(150,1)]; %% plot gscatter(x(:,1),x(:,2),y); %% train lda classifier c = classificationdiscriminant.fit(x,y); 

can please me plot hyperplane of separation c? suggestion great help.

furthermore, sample above in 2d, however, i'm interested in plotting them in 3d (i.e. sample data x has 3 columns). more great if can help.

borrowing example in matlab's classify() documentation:

class1 = 1; class2 = 2; k = c.coeffs(class1,class2).const; l = c.coeffs(class1,class2).linear; f = @(x,y) k + [x y]*l;  hold on; ezplot(f, [min(x(:,1)) max(x(:,1)) min(x(:,2)) max(x(:,2))]); 

note above example plots pairwise boundary between 2 classes in 2 dimensional space. if have additional classes, have modify class1 , class2 appropriately. i'm sure additional work can find extension of function n dimensional space.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -