42 SG_ADD(&
m_weights,
"m_weights",
"weights",MS_NOT_AVAILABLE)
61 REQUIRE(m_machine,
"m_machine is NULL. It is expected to be RandomCARTree\n")
67 REQUIRE(m_machine,
"m_machine is NULL. It is expected to be RandomCARTree\n")
73 REQUIRE(m_machine,
"m_machine is NULL. It is expected to be RandomCARTree\n")
79 REQUIRE(m_machine,
"m_machine is NULL. It is expected to be RandomCARTree\n")
85 REQUIRE(m_machine,
"m_machine is NULL. It is expected to be RandomCARTree\n")
86 REQUIRE(rand_featsize>0,
"feature subset size should be greater than 0\n")
88 dynamic_cast<CMyRandomCARTree*
>(m_machine)->set_feature_subset_size(rand_featsize);
93 REQUIRE(m_machine,
"m_machine is NULL. It is expected to be RandomCARTree\n")
94 return dynamic_cast<CMyRandomCARTree*
>(m_machine)->get_feature_subset_size();
99 REQUIRE(m,
"Machine supplied is NULL\n")
100 REQUIRE(m_machine,
"Reference Machine is NULL\n")
104 SGVector<float64_t> weights(idx.vlen);
108 weights.fill_vector(weights.vector,weights.vlen,1.0);
112 for (int32_t
i=0;
i<idx.vlen;
i++)
128 SG_UNREF(m_features);
132 REQUIRE(m_features,
"Training features not set!\n");
136 return CBaggingMachine::train_machine();
142 vector<double> importances(num_features, 0.0);
144 for (int32_t
i = 0;
i < m_num_bags; ++
i)
150 for(
size_t j = 0; j < num_features; j++)
151 importances[j] += m_imp[j];
154 for(
size_t i = 0;
i < num_features;
i++)
155 importances[
i] += m_num_bags;
162 SGMatrix<float64_t> output = apply_outputs_without_combination(data);
164 CMeanRule* mean_rule =
new CMeanRule();
166 SGVector<float64_t> probabilities = mean_rule->combine(output);
168 labels->set_values(probabilities);
void set_weights(SGVector< float64_t > w)
std::vector< double > feature_importances()
void set_machine_problem_type(EProblemType mode)
void set_sorted_features(SGMatrix< float64_t > &sorted_feats, SGMatrix< index_t > &sorted_indices)
This class implements randomized CART algorithm used in the tree growing process of candidate trees i...
SGVector< bool > get_feature_types() const
std::vector< double > feature_importances()
void set_probabilities(CLabels *labels, CFeatures *data=NULL)
virtual bool train_machine(CFeatures *data=NULL)
virtual void set_machine_parameters(CMachine *m, SGVector< index_t > idx)
int32_t get_num_random_features() const
SGVector< float64_t > m_weights
virtual EProblemType get_machine_problem_type() const
SGMatrix< float64_t > m_sorted_transposed_feats
virtual ~CMyRandomForest()
void set_num_random_features(int32_t rand_featsize)
void set_feature_types(SGVector< bool > ft)
SGVector< float64_t > get_weights() const
void set_machine_problem_type(EProblemType mode)
SGMatrix< index_t > m_sorted_indices
void set_weights(SGVector< float64_t > weights)