testGPHIKClassifierMex.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 = GPHIKClassifierMex ( 'new', 'verbose', 'false', ...
  14. 'optimization_method', 'none', 'varianceApproximation', 'approximate_rough',...
  15. 'nrOfEigenvaluesToConsiderForVarApprox',4,...
  16. 'uncertaintyPredictionForClassification', false ...
  17. );
  18. % run train method
  19. GPHIKClassifierMex ( 'train', myGPHIKClassifier, myData, myLabels);
  20. myDataTest = [ 0.3 0.4 0.3
  21. ];
  22. myLabelsTest = [1];
  23. % run single classification call
  24. [ classNoEst, score, uncertainty] = GPHIKClassifierMex ( 'classify', myGPHIKClassifier, myDataTest )
  25. % compute predictive variance
  26. uncertainty = GPHIKClassifierMex ( 'uncertainty', myGPHIKClassifier, myDataTest )
  27. % run test method evaluating arr potentially using multiple examples
  28. [ arr, confMat, scores] = GPHIKClassifierMex ( 'test', myGPHIKClassifier, myDataTest, myLabelsTest )
  29. % add a single new example
  30. newExample = [ 0.5 0.5 0.0
  31. ];
  32. newLabel = [4];
  33. GPHIKClassifierMex ( 'addExample', myGPHIKClassifier, newExample, newLabel);
  34. % add mutiple new examples
  35. newExamples = [ 0.3 0.3 0.4;
  36. 0.1, 0.2, 0.7
  37. ];
  38. newLabels = [1,3];
  39. GPHIKClassifierMex ( 'addMultipleExamples', myGPHIKClassifier, newExamples, newLabels );
  40. % perform evaluation again
  41. % run single classification call
  42. [ classNoEst, score, uncertainty] = GPHIKClassifierMex ( 'classify', myGPHIKClassifier, myDataTest )
  43. % compute predictive variance
  44. uncertainty = GPHIKClassifierMex ( 'uncertainty', myGPHIKClassifier, myDataTest )
  45. % run test method evaluating arr potentially using multiple examples
  46. [ arr, confMat, scores] = GPHIKClassifierMex ( 'test', myGPHIKClassifier, myDataTest, myLabelsTest )
  47. % clean up and delete object
  48. GPHIKClassifierMex ( 'delete',myGPHIKClassifier);