Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,26 @@ void Forest::init(std::unique_ptr<Data> input_data, uint mtry, std::string outpu
}
}

void Forest::loadDataForPrediction(std::unique_ptr<Data> input_data, std::vector<bool>& is_ordered_variable, bool predict_all) {
this->data = std::move(input_data);
this->prediction_mode = true;
this->predict_all = predict_all;

// Set number of samples and variables
num_samples = data->getNumRows();
num_independent_variables = data->getNumCols();

// Set unordered factor variables
data->setIsOrderedVariable(is_ordered_variable);

initInternal();

// Permute samples for corrected Gini importance
if (importance_mode == IMP_GINI_CORRECTED) {
data->permuteSampleIDs(random_number_generator);
}
}

void Forest::run(bool verbose, bool compute_oob_error) {

if (prediction_mode) {
Expand Down
1 change: 1 addition & 0 deletions src/Forest.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Forest {
bool order_snps, uint max_depth, const std::vector<double>& regularization_factor, bool regularization_usedepth,
bool node_stats);
virtual void initInternal() = 0;
void loadDataForPrediction(std::unique_ptr<Data> input_data, std::vector<bool>& is_ordered_variable, bool predict_all = false);

// Grow or predict
void run(bool verbose, bool compute_oob_error);
Expand Down