testGPHIKClassifierMex.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. % brief: Demo-program showing how to use the GPHIK Interface (without a class wrapper)
  2. % author: Alexander Freytag
  3. % date: 07-01-2014 (dd-mm-yyyy)
  4. myData = [ 0.2 0.3 0.5;
  5. 0.3 0.2 0.5;
  6. 0.9 0.0 0.1;
  7. 0.8 0.1 0.1;
  8. 0.1 0.1 0.8;
  9. 0.1 0.0 0.9
  10. ];
  11. myLabels = [1,1,2,2,3,3];
  12. % init new GPHIKClassifier object
  13. myGPHIKClassifier = GPHIKClassifier ( ...
  14. 'verbose', 'false', ...
  15. 'optimization_method', 'none', ...
  16. 'varianceApproximation', 'approximate_rough',...
  17. 'nrOfEigenvaluesToConsiderForVarApprox',4,...
  18. 'uncertaintyPredictionForClassification', false ...
  19. );
  20. % run train method
  21. myGPHIKClassifier.train( myData, myLabels );
  22. myDataTest = [ 0.3 0.4 0.3
  23. ];
  24. myLabelsTest = [1];
  25. % run single classification call
  26. [ classNoEst, score, uncertainty] = myGPHIKClassifier.classify( myDataTest )
  27. % compute predictive variance
  28. uncertainty = myGPHIKClassifier.uncertainty( myDataTest )
  29. % run test method evaluating arr potentially using multiple examples
  30. [ arr, confMat, scores] = myGPHIKClassifier.test( myDataTest, myLabelsTest )
  31. % add a single new example
  32. newExample = [ 0.5 0.5 0.0
  33. ];
  34. newLabel = [4];
  35. myGPHIKClassifier.addExample( newExample, newLabel );
  36. % add mutiple new examples
  37. newExamples = [ 0.3 0.3 0.4;
  38. 0.1, 0.2, 0.7
  39. ];
  40. newLabels = [1,3];
  41. myGPHIKClassifier.addMultipleExamples( newExamples, newLabels );
  42. % perform evaluation again
  43. % run single classification call
  44. [ classNoEst, score, uncertainty] = myGPHIKClassifier.classify( myDataTest )
  45. % compute predictive variance
  46. uncertainty = myGPHIKClassifier.uncertainty( myDataTest )
  47. % run test method evaluating arr potentially using multiple examples
  48. [ arr, confMat, scores] = myGPHIKClassifier.test( myDataTest, myLabelsTest )
  49. % clean up and delete object
  50. myGPHIKClassifier.delete();
  51. clear ( 'myGPHIKClassifier' );