fork download
  1. class CPairTree{
  2.  
  3. public:
  4.  
  5. CPairTree( );
  6. CPairTree(const HyperParameters &);
  7. CPairTree(const HyperParameters &, const xmlNodePtr );
  8. CPairTree(const HyperParameters &, const xmlNodePtr, int );
  9. ~CPairTree();
  10.  
  11. xmlNodePtr save() const;
  12. void save(const std::string &name, int = 0);
  13.  
  14. void train(const matrix<float>& data, const std::vector<int>& labels );
  15. void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<double>& weights);
  16.  
  17. void train(const matrix<float>&, const std::vector<int>&, matrix<float>&, matrix<float>&, std::vector<int>& );
  18. void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<double>& weights,
  19. matrix<float>& forestConfidences, matrix<float>& forestOutOfBagConfidences, std::vector<int>& forestOutOfBagVoteNum);
  20.  
  21.  
  22.  
  23. void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<Pair> & vPosPairs, const std::vector<Pair> & vNegPairs);
  24.  
  25. void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<double>& weights, const std::vector<Pair> & vPosPairs, const std::vector<Pair> & vNegPairs);
  26.  
  27. //void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<double>& weights,
  28. // const std::vector<Pair> & vPosPairs, const std::vector<double>& posPairWeights,
  29. // const std::vector<Pair> & vNegPairs, const std::vector<double>& negPairWeights);
  30.  
  31. void train(const matrix<float>& data, const std::vector<int>& labels,
  32. const std::vector<Pair> & vPosPairs, const std::vector<std::pair<int,int> > & vPosPairLabels, const std::vector<double>& posPairWeights,
  33. const std::vector<Pair> & vNegPairs, const std::vector<std::pair<int,int> > & vNegPairLabels, const std::vector<double>& negPairWeights);
  34.  
  35. void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<double>& weights,
  36. const std::vector<Pair> & vPosPairs, const std::vector<std::pair<int,int> > & vPosPairLabels, const std::vector<double>& posPairWeights,
  37. const std::vector<Pair> & vNegPairs, const std::vector<std::pair<int,int> > & vNegPairLabels, const std::vector<double>& negPairWeights);
  38.  
  39. void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<Pair> & vPosPairs, const std::vector<Pair> & vNegPairs,
  40. matrix<float>& forestConfidences, matrix<float>& forestOutOfBagConfidences, std::vector<int>& forestOutOfBagVoteNum);
  41.  
  42. void train(const matrix<float>& data, const std::vector<int>& labels, const std::vector<double>& weights, const std::vector<Pair> & vPosPairs, const std::vector<Pair> & vNegPairs,
  43. matrix<float>& forestConfidences, matrix<float>& forestOutOfBagConfidences, std::vector<int>& forestOutOfBagVoteNum);
  44.  
  45. void eval(const matrix<float>&, const std::vector<int>&);
  46.  
  47. void eval(const matrix<float>&, const std::vector<int>&, matrix<float>& );
  48.  
  49. inline std::vector<int> getPredictions() const { return m_predictions; };
  50. inline std::vector<int> getInBagSamples() const { return m_inBagSamples; };
  51. inline std::vector<int> getOutOfBagSamples() const { return m_outOfBagSamples; };
  52. inline matrix<float> getConfidences() const { return m_confidences; };
  53. inline int getNumNodes() const { return m_rootNode->numNodes(); };
  54. inline int getTreeID() const{ return m_nTreeID; };
  55.  
  56. void setInBagSamples(const std::vector<int>& inBagSamples) { m_inBagSamples = inBagSamples; };
  57. void setOutOfBagSamples(const std::vector<int>& outOfBagSamples) { m_outOfBagSamples = outOfBagSamples; };
  58. void setTreeID( int treeID ) { m_nTreeID = treeID; };
  59.  
  60. void getTreeAsMatrix(matrix<float> *, const int);
  61. std::vector<std::vector<int> > getPath(const matrix<float>& );
  62. int getDepth();
  63. std::vector<int> getNodeLabels();
  64. void clean();
  65.  
  66. //cout << "Global gini time: " << timeGini << endl;
  67. //cout << "Global entropy time: " << timeEntropy << endl;
  68.  
  69. private:
  70.  
  71. int m_nTreeID;
  72. HyperParameters m_hp;
  73. CPairNode::Ptr m_rootNode;
  74.  
  75. matrix<float> m_confidences;
  76. std::vector<int> m_predictions;
  77. std::vector<int> m_inBagSamples;
  78. std::vector<int> m_outOfBagSamples;
  79.  
  80. std::vector<int> m_inPosPairsBagSamples;
  81. std::vector<int> m_inNegPairsBagSamples;
  82.  
  83. void initialize(const int); // Create the confidence matrices and prediction vectors
  84. void reInitialize(const int); // Create the confidence matrices and prediction vectors
  85.  
  86. void subSample(const int); // Create bags
  87. void subSample(const int, const std::vector<double>&); // Create bags
  88.  
  89. void finalize(const matrix<float>&, matrix<float>& , matrix<float>& , std::vector<int>& );
  90.  
  91. double computeError(const std::vector<int>& labels);
  92. double computeError(const std::vector<int>& labels, const std::vector<int>& sampleIndeces);
  93.  
  94. void getTreeAsMatrixRecursive(CPairNode::Ptr current_node, matrix<float> *data, const int tree_index, const int node_index);
  95.  
  96. void evalOutOfBagSamples(const matrix<float>& data);
  97. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:20: error: 'HyperParameters' does not name a type
prog.cpp:6:36: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:7:20: error: 'HyperParameters' does not name a type
prog.cpp:7:36: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:7:45: error: 'xmlNodePtr' does not name a type
prog.cpp:7:45: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:8:20: error: 'HyperParameters' does not name a type
prog.cpp:8:36: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:8:45: error: 'xmlNodePtr' does not name a type
prog.cpp:8:45: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:11:4: error: 'xmlNodePtr' does not name a type
prog.cpp:12:20: error: 'string' in namespace 'std' does not name a type
prog.cpp:12:33: error: ISO C++ forbids declaration of 'name' with no type
prog.cpp:14:21: error: 'matrix' does not name a type
prog.cpp:14:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:14:27: error: expected ',' or '...' before '<' token
prog.cpp:15:21: error: 'matrix' does not name a type
prog.cpp:15:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:15:27: error: expected ',' or '...' before '<' token
prog.cpp:15:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:17:21: error: 'matrix' does not name a type
prog.cpp:17:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:17:27: error: expected ',' or '...' before '<' token
prog.cpp:17:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:18:21: error: 'matrix' does not name a type
prog.cpp:18:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:18:27: error: expected ',' or '...' before '<' token
prog.cpp:18:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:23:21: error: 'matrix' does not name a type
prog.cpp:23:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:23:27: error: expected ',' or '...' before '<' token
prog.cpp:23:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:25:21: error: 'matrix' does not name a type
prog.cpp:25:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:25:27: error: expected ',' or '...' before '<' token
prog.cpp:25:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:31:21: error: 'matrix' does not name a type
prog.cpp:31:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:31:27: error: expected ',' or '...' before '<' token
prog.cpp:31:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:35:21: error: 'matrix' does not name a type
prog.cpp:35:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:35:27: error: expected ',' or '...' before '<' token
prog.cpp:35:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:39:21: error: 'matrix' does not name a type
prog.cpp:39:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:39:27: error: expected ',' or '...' before '<' token
prog.cpp:39:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:42:21: error: 'matrix' does not name a type
prog.cpp:42:21: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:42:27: error: expected ',' or '...' before '<' token
prog.cpp:42:9: error: 'void CPairTree::train(int)' cannot be overloaded
prog.cpp:14:9: error: with 'void CPairTree::train(int)'
prog.cpp:45:20: error: 'matrix' does not name a type
prog.cpp:45:20: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:45:26: error: expected ',' or '...' before '<' token
prog.cpp:47:20: error: 'matrix' does not name a type
prog.cpp:47:20: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:47:26: error: expected ',' or '...' before '<' token
prog.cpp:47:9: error: 'void CPairTree::eval(int)' cannot be overloaded
prog.cpp:45:9: error: with 'void CPairTree::eval(int)'
prog.cpp:49:11: error: 'vector' in namespace 'std' does not name a type
prog.cpp:50:11: error: 'vector' in namespace 'std' does not name a type
prog.cpp:51:11: error: 'vector' in namespace 'std' does not name a type
prog.cpp:52:11: error: 'matrix' does not name a type
prog.cpp:56:31: error: 'vector' in namespace 'std' does not name a type
prog.cpp:56:36: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:56:42: error: expected ',' or '...' before '<' token
prog.cpp:57:34: error: 'vector' in namespace 'std' does not name a type
prog.cpp:57:39: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:57:45: error: expected ',' or '...' before '<' token
prog.cpp:60:25: error: 'matrix' has not been declared
prog.cpp:60:31: error: expected ',' or '...' before '<' token
prog.cpp:61:4: error: 'vector' in namespace 'std' does not name a type
prog.cpp:63:4: error: 'vector' in namespace 'std' does not name a type
prog.cpp:72:4: error: 'HyperParameters' does not name a type
prog.cpp:73:4: error: 'CPairNode' does not name a type
prog.cpp:75:4: error: 'matrix' does not name a type
prog.cpp:76:4: error: 'vector' in namespace 'std' does not name a type
prog.cpp:77:4: error: 'vector' in namespace 'std' does not name a type
prog.cpp:78:4: error: 'vector' in namespace 'std' does not name a type
prog.cpp:80:4: error: 'vector' in namespace 'std' does not name a type
prog.cpp:81:4: error: 'vector' in namespace 'std' does not name a type
prog.cpp:87:36: error: 'vector' in namespace 'std' does not name a type
prog.cpp:87:41: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:87:47: error: expected ',' or '...' before '<' token
prog.cpp:89:24: error: 'matrix' does not name a type
prog.cpp:89:24: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:89:30: error: expected ',' or '...' before '<' token
prog.cpp:91:30: error: 'vector' in namespace 'std' does not name a type
prog.cpp:91:35: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:91:41: error: expected ',' or '...' before '<' token
prog.cpp:92:30: error: 'vector' in namespace 'std' does not name a type
prog.cpp:92:35: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:92:41: error: expected ',' or '...' before '<' token
prog.cpp:92:11: error: 'double CPairTree::computeError(int)' cannot be overloaded
prog.cpp:91:11: error: with 'double CPairTree::computeError(int)'
prog.cpp:94:34: error: 'CPairNode' has not been declared
prog.cpp:94:49: error: expected ',' or '...' before 'current_node'
prog.cpp:96:35: error: 'matrix' does not name a type
prog.cpp:96:35: error: ISO C++ forbids declaration of 'parameter' with no type
prog.cpp:96:41: error: expected ',' or '...' before '<' token
prog.cpp: In member function 'int CPairTree::getNumNodes() const':
prog.cpp:53:44: error: 'm_rootNode' was not declared in this scope
prog.cpp: In member function 'void CPairTree::setInBagSamples(int)':
prog.cpp:56:65: error: 'm_inBagSamples' was not declared in this scope
prog.cpp:56:82: error: 'inBagSamples' was not declared in this scope
prog.cpp: In member function 'void CPairTree::setOutOfBagSamples(int)':
prog.cpp:57:71: error: 'm_outOfBagSamples' was not declared in this scope
prog.cpp:57:91: error: 'outOfBagSamples' was not declared in this scope
stdout
Standard output is empty