How to generate polynomial matrix in classification problems ?

조회 수: 1 (최근 30일)
Abdelwahab Afifi
Abdelwahab Afifi 2020년 3월 18일
편집: Abdelwahab Afifi 2020년 3월 20일
I have the fllowing samples [1 2] , [2 0] , [1 1], [3 1], [2 3], [3 3] which correspond to labels y : {0, 0, 0, 1, 1, 1} respectively. Our goal is to predict the class label of xt1=[4 1] and xt2=[1 0] .
I already simulate the 3) MSE using indicator Matrix as follow:
clc; clear all; close all;
s1=[1 2];
s2=[2 0];
s3=[1 1];
s4=[3 1];
s5=[2 3];
s6=[3 3];
S=[s1;s2;s3;s4;s5;s6];
xt1=[4 1];
xt2=[1 0];
disp('MSE using Indicator Matrix (Primal)')
X=Xo
Y=[ones(3,1) zeros(3,1);zeros(3,1) ones(3,1)]
w=inv(X'*X)*X'*Y
predict1=[1 xt1]*w
predict2=[1 xt2]*w
predict=[1 xt1; 1 xt2]*w
However, in case of MSE with polynomial, how can I calculate matrix P in case of 2'nd order and 3'rd order polynomial ?! to get the same results. I tried the following code, but can't obtain the same results.
% MSE with Polynomial (Dual)
X=[ones(6,1) S S.^2 S(:,1).*S(:,2)]
Y=[ones(3,1) zeros(3,1);zeros(3,1) ones(3,1)]
w=X'*inv(X*X')*Y % Dual
predict1=[1 xt1 xt1.^2 xt1(1)*xt1(2)]*w
predict1=[1 xt2 xt2.^2 xt2(1)*xt2(2)]*w

답변 (0개)

카테고리

Help CenterFile Exchange에서 Classification에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by