%load iris dataset
load fisheriris;
figure(1);
gscatter(meas(:,1), meas(:,2), species,'rgb','osd');
title('iris')
xlabel('Sepal Length');ylabel('Sepal Width');

%% kernel pca
data=meas';
data_output=kernelpca(data,2);
data_kernelpca=data_output'
figure(2)
gscatter(data_kernelpca(:,1),data_kernelpca(:,2),species,'rgb','osd');
title('kernel pca')
xlabel('Sepal Length');ylabel('Sepal Width');
figure(3);
gscatter(data_kernelpca(:,1),zeros(150,1),species,'rgb','osd')
title('kernel pca project onto X-axis')
xlabel('Sepal Length');ylabel('Sepal Width');


%% Multidimensional Scaling

% Computer the euclidean distance beteween pairs of objects in data matrix
d=pdist(meas,'euclidean');

%Choices for metric scaling, squared stress, normalized with the sum of 4th powers of the dissimilarities. 
data_MDS = mdscale(d,2,'criterion','metricsstress')

figure(4)
gscatter(data_MDS(:,1),data_MDS(:,2),species,'rgb','osd');
title('Multidimesion Scaling');
xlabel('Sepal Length');
ylabel('Sepal Width');

figure(5);
gscatter(data_MDS(:,1),zeros(150,1),species,'rgb','osd')
title('MDS project onto X-axis');
xlabel('Sepal Length');
ylabel('Sepal Width');
