Explorar el Código

Matlab visualizations with smarter layout

Alexander Freytag hace 11 años
padre
commit
96d161ae63
Se han modificado 3 ficheros con 90 adiciones y 19 borrados
  1. 4 4
      matlab/Makefile
  2. 39 6
      matlab/plot1dExampleClassification.m
  3. 47 9
      matlab/plot1dExampleRegression.m

+ 4 - 4
matlab/Makefile

@@ -2,11 +2,11 @@ NICEFLAGS1=$(shell pkg-config libgp-hik-core --cflags --libs)
 NICEFLAGS=$(subst -fopenmp,,$(NICEFLAGS1))
 
 default:
-	/home/alex/bin/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKClassifierMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp
-	/home/alex/bin/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKRegressionMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp
+	/home/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKClassifierMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp
+	/home/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKRegressionMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp
 
 classification:
-	/home/alex/bin/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKClassifierMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp
+	/home/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKClassifierMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp
 
 regression:        
-	/home/alex/bin/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKRegressionMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp
+	/home/matlab/7.14/bin/mex ${NICEFLAGS} -largeArrayDims GPHIKRegressionMex.cpp ConverterMatlabToNICE.cpp ConverterNICEToMatlab.cpp

+ 39 - 6
matlab/plot1dExampleClassification.m

@@ -1,14 +1,19 @@
-myData = [ 0.2; 0.8];
+% BRIEF: Small visualization script using GPHIKClassifier
+% author: Alexander Freytag
+% date: 20-01-2014 (dd-mm-yyyy)
+
+myData = [ 0.2; 0.6; 0.9];
 % create l1-normalized 'histograms'
-myData = cat(2,myData , 1-myData)';
-myLabels = [1,2];
+myData = cat(2,myData , 1-myData);
+myLabels = [1; 2; 2];
 
 
 % init new GPHIKClassifier object
 myGPHIKClassifier = GPHIKClassifier ( 'verbose', 'false', ...
     'optimization_method', 'none', 'varianceApproximation', 'approximate_fine',...
     'nrOfEigenvaluesToConsiderForVarApprox',2,...
-    'uncertaintyPredictionForClassification', true ...
+    'uncertaintyPredictionForClassification', true, ...
+    'noise', 0.000001 ...
     );
 
 % run train method
@@ -28,8 +33,10 @@ for i=1:size(myDataTest,1)
 end
 
 
+% create figure and set title
+classificationFig = figure;
+set ( classificationFig, 'name', 'Classification with GPHIK');
 
-figure;
 hold on;
 
 %#initialize x array
@@ -48,7 +55,33 @@ Y=[uncLower',fliplr(uncUpper')];
 %#plot filled area
 fill(X,Y,'y');                  
 
-plot ( x,scores,'rx');
+% plot mean values
+plot ( x,scores, ...
+       'LineStyle', '--', ...
+       'LineWidth', 2, ...
+       'Color', 'r', ...
+       'Marker','none', ...
+       'MarkerSize',1, ...
+       'MarkerEdgeColor','r', ...
+       'MarkerFaceColor',[0.5,0.5,0.5] ...
+       );
+
+% plot training data
+plot ( myData(:,1), 2*(myLabels==1)-1, ...
+       'LineStyle', 'none', ...
+       'LineWidth', 3, ...
+       'Marker','o', ...
+       'MarkerSize',6, ...
+       'MarkerEdgeColor','b', ...
+       'MarkerFaceColor',[0.5,0.5,0.5] ...
+       );
+
+xlabel('1st Input dimension');
+ylabel('Classification score');   
+
+i_fontSizeAxis = 16;
+set(get(gca,'XLabel'), 'FontSize', i_fontSizeAxis);
+set(get(gca,'YLabel'), 'FontSize', i_fontSizeAxis);
 
 
 % clean up and delete object

+ 47 - 9
matlab/plot1dExampleRegression.m

@@ -1,16 +1,25 @@
-myData = [ 0.1; 0.3; 0.8];
+% BRIEF: Small visualization script using the GPHIKRegression
+% author: Alexander Freytag
+% date: 20-01-2014 (dd-mm-yyyy)
+
+myData = [ 0.1; 0.3; 0.7; 0.8];
 % create l1-normalized 'histograms'
 myData = cat(2,myData , 1-myData);
-myValues = [0.3; 0.0; 1.4];
+myValues = [0.3; 0.0; 1.0; 1.4];
 
 
 % init new GPHIKRegression object
 myGPHIKRegression = GPHIKRegression ( 'verbose', 'false', ...
-    'optimization_method', 'none', 'varianceApproximation', 'approximate_fine',...
-    'nrOfEigenvaluesToConsiderForVarApprox',2,...
-    'uncertaintyPredictionForRegression', true ...
+    'optimization_method', 'none', ...
+    'varianceApproximation', 'approximate_fine',...
+    'nrOfEigenvaluesToConsiderForVarApprox',1,...
+    'uncertaintyPredictionForRegression', true, ...
+    'noise', 0.000001 ...
     );
 
+    %'varianceApproximation', 'approximate_fine',...
+    %'varianceApproximation', 'exact',...
+
 % run train method
 myGPHIKRegression.train( myData, myValues );
 
@@ -27,8 +36,10 @@ for i=1:size(myDataTest,1)
 end
 
 
+% create figure and set title
+classificationFig = figure;
+set ( classificationFig, 'name', 'Regression with GPHIK');
 
-figure;
 hold on;
 
 %#initialize x array
@@ -44,11 +55,38 @@ uncUpper=scores+uncertainties;
 X=[x,fliplr(x)];
 %# concatenate y-values accordingly
 Y=[uncLower',fliplr(uncUpper')]; 
-%#plot filled area
+%#plot filled area for predictive variance ( aka regression uncertainty )
 fill(X,Y,'y');                  
 
-plot ( x,scores,'rx');
-
+% plot mean values
+plot ( x,scores, ...
+       'LineStyle', '--', ...
+       'LineWidth', 2, ...
+       'Color', 'r', ...
+       'Marker','none', ...
+       'MarkerSize',1, ...
+       'MarkerEdgeColor','r', ...
+       'MarkerFaceColor',[0.5,0.5,0.5] ...
+       );
+
+% plot training data
+plot ( myData(:,1), myValues, ...
+       'LineStyle', 'none', ...
+       'LineWidth', 3, ...
+       'Marker','o', ...
+       'MarkerSize',6, ...
+       'MarkerEdgeColor','b', ...
+       'MarkerFaceColor',[0.5,0.5,0.5] ...
+       );
+
+xlabel('1st Input dimension');
+ylabel('Regression score');   
+
+i_fontSizeAxis = 16;
+set(get(gca,'XLabel'), 'FontSize', i_fontSizeAxis);
+set(get(gca,'YLabel'), 'FontSize', i_fontSizeAxis);
+
+   
 
 % clean up and delete object
 myGPHIKRegression.delete();