Skip to content
Merged
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
11 changes: 9 additions & 2 deletions src/forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ void initialize_forest_model_cpp(cpp11::external_pointer<StochTree::ForestDatase
else if (leaf_model_int == 1) model_type = StochTree::ModelType::kUnivariateRegressionLeafGaussian;
else if (leaf_model_int == 2) model_type = StochTree::ModelType::kMultivariateRegressionLeafGaussian;
else if (leaf_model_int == 3) model_type = StochTree::ModelType::kLogLinearVariance;
else if (leaf_model_int == 4) model_type = StochTree::ModelType::kCloglogOrdinal;
else StochTree::Log::Fatal("Invalid model type");

// Unpack initial value
Expand All @@ -500,7 +501,8 @@ void initialize_forest_model_cpp(cpp11::external_pointer<StochTree::ForestDatase
std::vector<double> init_value_vector;
if ((model_type == StochTree::ModelType::kConstantLeafGaussian) ||
(model_type == StochTree::ModelType::kUnivariateRegressionLeafGaussian) ||
(model_type == StochTree::ModelType::kLogLinearVariance)) {
(model_type == StochTree::ModelType::kLogLinearVariance) ||
(model_type == StochTree::ModelType::kCloglogOrdinal)) {
init_val = init_values.at(0);
} else if (model_type == StochTree::ModelType::kMultivariateRegressionLeafGaussian) {
int leaf_dim = init_values.size();
Expand Down Expand Up @@ -529,6 +531,10 @@ void initialize_forest_model_cpp(cpp11::external_pointer<StochTree::ForestDatase
int n = data->NumObservations();
std::vector<double> initial_preds(n, init_val);
data->AddVarianceWeights(initial_preds.data(), n);
} else if (model_type == StochTree::ModelType::kCloglogOrdinal) {
forest_samples->InitializeRoot(init_val / static_cast<double>(num_trees));
UpdateResidualEntireForest(*tracker, *data, *residual, forest_samples->GetEnsemble(0), false, std::minus<double>());
tracker->UpdatePredictions(forest_samples->GetEnsemble(0), *data);
}
}

Expand Down Expand Up @@ -816,7 +822,8 @@ void initialize_forest_model_active_forest_cpp(cpp11::external_pointer<StochTree
std::vector<double> init_value_vector;
if ((model_type == StochTree::ModelType::kConstantLeafGaussian) ||
(model_type == StochTree::ModelType::kUnivariateRegressionLeafGaussian) ||
(model_type == StochTree::ModelType::kLogLinearVariance)) {
(model_type == StochTree::ModelType::kLogLinearVariance) ||
(model_type == StochTree::ModelType::kCloglogOrdinal)) {
init_val = init_values.at(0);
} else if (model_type == StochTree::ModelType::kMultivariateRegressionLeafGaussian) {
int leaf_dim = init_values.size();
Expand Down
Loading