13 #ifndef KOHO_DECISION_FOREST_H 14 #define KOHO_DECISION_FOREST_H 47 std::vector<DecisionTreeClassifier>
dtc_;
117 std::vector<std::string> features,
119 unsigned long n_estimators = 100,
120 bool bootstrap =
false,
121 bool oob_score =
false,
122 std::string
const& class_balance =
"balanced",
125 unsigned long max_thresholds = 0,
126 std::string
const& missing_values =
"None",
127 long random_state_seed = 0);
214 void export_graphviz(std::string
const& filename,
unsigned long e,
bool rotate);
void serialize(std::ofstream &fout)
Serialize.
Definition: decision_forest.cpp:390
Definition: decision_forest.cpp:20
unsigned long ClassesIdx_t
Definition: decision_tree.h:46
unsigned long TreeDepthIdx_t
Definition: decision_tree.h:48
unsigned long max_thresholds
Definition: decision_forest.h:40
RandomState random_state
Definition: decision_forest.h:44
unsigned long FeaturesIdx_t
Definition: decision_tree.h:45
std::string export_text(unsigned long e)
Export of a decision tree from a decision forest in a simple text format.
Definition: decision_forest.cpp:382
A decision forest classifier.
Definition: decision_forest.h:25
A random number generator.
Definition: random_number_generator.h:20
std::vector< std::string > features
Definition: decision_forest.h:30
double oob_score_
Definition: decision_forest.h:50
FeaturesIdx_t n_features
Definition: decision_forest.h:31
void calculate_feature_importances(double *importances)
Calculate feature importances from the decision forest.
Definition: decision_forest.cpp:340
std::vector< std::string > classes
Definition: decision_forest.h:28
static DecisionForestClassifier import_deserialize(std::string const &filename)
Definition: decision_forest.cpp:537
void predict_proba(Features_t *X, SamplesIdx_t n_samples, double *y_prob)
Predict classes probabilities for the test data.
Definition: decision_forest.cpp:276
void export_graphviz(std::string const &filename, bool rotate=false)
Export of a decision forest as individual decision trees in GraphViz dot format.
Definition: decision_forest.cpp:364
std::string class_balance
Definition: decision_forest.h:37
double score(Features_t *X, Classes_t *y, SamplesIdx_t n_samples)
Calculate score for the test data.
Definition: decision_forest.cpp:323
TreeDepthIdx_t max_depth
Definition: decision_forest.h:38
long Classes_t
Definition: decision_tree.h:39
bool bootstrap
Definition: decision_forest.h:35
ClassesIdx_t n_classes
Definition: decision_forest.h:29
bool oob_score
Definition: decision_forest.h:36
void export_serialize(std::string const &filename)
Definition: decision_forest.cpp:433
void predict(Features_t *X, SamplesIdx_t n_samples, Classes_t *y)
Predict classes for the test data.
Definition: decision_forest.cpp:308
static DecisionForestClassifier deserialize(std::ifstream &fin)
Deserialize.
Definition: decision_forest.cpp:462
unsigned long n_estimators
Definition: decision_forest.h:34
DecisionForestClassifier(std::vector< std::string > classes, ClassesIdx_t n_classes, std::vector< std::string > features, FeaturesIdx_t n_features, unsigned long n_estimators=100, bool bootstrap=false, bool oob_score=false, std::string const &class_balance="balanced", TreeDepthIdx_t max_depth=3, FeaturesIdx_t max_features=0, unsigned long max_thresholds=0, std::string const &missing_values="None", long random_state_seed=0)
Create and initialize a new decision forest classifier.
Definition: decision_forest.cpp:28
double Features_t
Definition: decision_tree.h:38
std::string missing_values
Definition: decision_forest.h:41
void fit(Features_t *X, Classes_t *y, SamplesIdx_t n_samples)
Build a decision forest classifier from the training data.
Definition: decision_forest.cpp:106
std::vector< DecisionTreeClassifier > dtc_
Definition: decision_forest.h:47
unsigned long SamplesIdx_t
Definition: decision_tree.h:44
FeaturesIdx_t max_features
Definition: decision_forest.h:39