📄 showresults.m
字号:
%=====================================================================
%
% ShowResults% ----------------%% Parameters: % Samples - This matrix holds the data points.
% SV - A Matrix containing the Support vectors.
% BSV - A Matrix containing the outliers.
% R - The minimal sphere's radius.
% beta - The vector of the Lagrangian multipliers.
% quad - The quadratic part of the distace from the sphere's
% center.
% q - The width of the gaussian kernel.% clusters_assignments -
% A vector of the clusters assignments assigned by the algorithm
% to the data points.
% grids - Each layer in this matrix holds a grid mapping for
% - a couple of dimensions.
% grids_sizes - The number of points in each grid layer.
% classifications - The apriori classifications for each Data point.
% nof_samples_per_class_per_cluster
%
% Shows graphs of the aquired results.
%
%=====================================================================
function ShowResults(Samples,SV,BSV,R,beta,quad,q,clusters_assignments,grids, grids_sizes,classifications,nof_samples_per_class_per_cluster);
[attr,N] = size(Samples);
grid_index = 0;
for attr1 = 1:attr-1
for attr2 = attr1+1:attr
% Plot the data points, highlights SVs and BSVs
figure;
plot(Samples(attr1,:),Samples(attr2,:),'bd',BSV(attr1,:),BSV(attr2,:),'r*',SV(attr1,:),SV(attr2,:),'g*');
title(strcat('The Sample Points and the Support Vectors - Dimensions:',num2str(attr1),' and:',num2str(attr2)));
xlabel(strcat('Attribute: ',num2str(attr1)));
ylabel(strcat('Attribute: ',num2str(attr2)));
%legend ('Samples', 'Bounded Suuport Vectors' ,'Support Vectors',-1);
% show the 2d mapping of the clusters
grid_index = grid_index+1;
figure;
plot(grids(1:grids_sizes(grid_index),1,grid_index),grids(1:grids_sizes(grid_index),2,grid_index),'k.',Samples(attr1,:),Samples(attr2,:),'bd');
title(strcat('The Sphere Mapping into a 2D space - Dimension:',num2str(attr1),' and:',num2str(attr2)));
xlabel(strcat('Attribute: ',num2str(attr1)));
ylabel(strcat('Attribute: ',num2str(attr2)));
%legend ('Grid Points','Samples',-1);
% shows the different clusters
ShowClusters([Samples(attr1,:);Samples(attr2,:)],clusters_assignments,attr1,attr2);
end
end
unique_classifications = unique(classifications);
figure;
bar(nof_samples_per_class_per_cluster,'stacked');
title('Classfications Per Class');
xlabel('Clusters');
ylabel('Number of Samples of each class');
% create the legend string
legend_str = 'legend('
for class = 1:length(unique_classifications);
if(class ~= 1)
legend_str = strcat(legend_str,',');
end
legend_str = strcat(legend_str, '''class:',num2str(unique_classifications(class)),'''');
end
legend_str = strcat(legend_str,');');
eval(legend_str);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -