00001
00006
#ifndef _RANDOM_FOREST_H_
00007
#define _RANDOM_FOREST_H_
00008
00009
#include <vector>
00010
00011
using namespace std;
00012
00013
namespace librf {
00014
00015
class Instance;
00016
class InstanceSet;
00017
class Tree;
00023 class RandomForest {
00024
public:
00026
RandomForest();
00028
RandomForest(
const InstanceSet& set,
00029
int num_trees,
00030
int K,
00031
int max_depth);
00032 ~
RandomForest();
00034
00036
00038
int predict(
const InstanceSet& set,
int instance_no)
const;
00040
float predict_prob(
const InstanceSet& set,
int instance_no,
int label)
const;
00042
float testing_accuracy(
const InstanceSet& testset)
const;
00044
float training_accuracy()
const;
00046
float oob_accuracy()
const;
00048
void variable_importance(vector< pair<float, int> >* ranking,
00049
unsigned int* seed)
const;
00051
void read(istream& i);
00053
void write(ostream& o);
00055
void print()
const;
00056
private:
00057
const InstanceSet& set_;
00058 vector<Tree*> trees_;
00059
int max_depth_;
00060
int K_;
00061 };
00062
00063 }
00064
#endif