testGPHIKClassifier.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. % brief: Demo-program showing how to use the GPHIKClassifier Interface (including the 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 ( 'verbose', 'false', ...
  14. 'optimization_method', 'none', 'varianceApproximation', 'approximate_fine',...
  15. 'nrOfEigenvaluesToConsiderForVarApprox',4,...
  16. 'uncertaintyPredictionForClassification', false ...
  17. );
  18. % run train method
  19. myGPHIKClassifier.train( myData, myLabels );
  20. % check the reclassification is working!
  21. [ arrReCl, confMatReCl, scoresReCl] = myGPHIKClassifier.test( myData, myLabels )
  22. uncertainty = myGPHIKClassifier.uncertainty( myData(1,:) )
  23. myDataTest = [ 0.3 0.4 0.3
  24. ];
  25. myLabelsTest = [1];
  26. % run single classification call
  27. [ classNoEst, score, uncertainty] = myGPHIKClassifier.classify( myDataTest )
  28. % compute predictive variance
  29. uncertainty = myGPHIKClassifier.uncertainty( myDataTest )
  30. % run test method evaluating arr potentially using multiple examples
  31. [ arr, confMat, scores] = myGPHIKClassifier.test( myDataTest, myLabelsTest )
  32. % add a single new example
  33. newExample = [ 0.5 0.5 0.0
  34. ];
  35. newLabel = [4];
  36. myGPHIKClassifier.addExample( newExample, newLabel);
  37. % add mutiple new examples
  38. newExamples = [ 0.3 0.3 0.4;
  39. 0.1, 0.2, 0.7
  40. ];
  41. newLabels = [1,3];
  42. myGPHIKClassifier.addMultipleExamples( newExamples, newLabels );
  43. % perform evaluation again
  44. % run single classification call
  45. [ classNoEst, score, uncertainty] = myGPHIKClassifier.classify( myDataTest )
  46. % compute predictive variance
  47. uncertainty = myGPHIKClassifier.uncertainty( myDataTest )
  48. % run test method evaluating arr potentially using multiple examples
  49. [ arr, confMat, scores] = myGPHIKClassifier.test( myDataTest, myLabelsTest )
  50. % clean up and delete object
  51. myGPHIKClassifier.delete();
  52. clear ( 'myGPHIKClassifier' );