@@ -3,6 +3,8 @@
#include <utility>
#include <vector>

#include <iostream>

#include "gradient_boosting/trees/GradientBoostingTreeOblivious.h"

namespace gradient_boosting {
@@ -31,21 +33,23 @@ GradientBoostingTreeOblivious::GetBestSplit(
const vector<vector<size_t>>& objects_in_nodes,
size_t train_feature) const {
auto loss_function_ptr = loss_function_.Clone();
std::cout << "Here we are in GetBestSplit " << " " << train_feature << " " << features_objects.size() << std::endl;
vector<vector<GradientBoostingSplitInfo>> feature_nodes_split_infos(
features_objects[train_feature].size(),
vector<GradientBoostingSplitInfo>(objects_in_nodes.size()));

std::cout << "Here we are in GetBestSplit[2]" << std::endl;
for (size_t node = 0; node < objects_in_nodes.size(); ++node) {
//std::cout << "Here we are " << node << " " << train_feature << " " << objects_in_nodes[node].size() << std::endl;
loss_function_ptr->Configure(train_feature, objects_in_nodes[node]);

//std::cout << "Here we are " << node << " " << train_feature << " " << objects_in_nodes.size() << std::endl;
for (size_t feature_split_value = 0;
feature_split_value < features_objects[train_feature].size();
++feature_split_value) {
feature_nodes_split_infos[feature_split_value][node] =
loss_function_ptr->GetLoss(feature_split_value);
}
}

//std::cout << "Here we are" << std::endl;
auto loss_lambda =
[&](size_t feature_split_value) {
return
@@ -118,9 +122,11 @@ void GradientBoostingTreeOblivious::Fit(
train_feature);
});
}
//std::cout << "Here we are" << std::endl;
for (size_t train_feature_num = 0;
train_feature_num < train_features.size();
train_feature_num += num_threads + 1) {
std::cout << "Here we are " << train_feature_num << " " << train_features.size()<< std::endl;
const size_t train_feature = train_features[train_feature_num];
features_best_splits[train_feature_num] = GetBestSplit(
features_objects,
@@ -129,7 +135,7 @@ void GradientBoostingTreeOblivious::Fit(
objects_in_nodes,
train_feature);
}

std::cout << "Here we are[2]" << std::endl;
for (size_t train_feature_num = 0;
train_feature_num < train_features.size();
++train_feature_num) {
@@ -154,13 +160,17 @@ void GradientBoostingTreeOblivious::Fit(
features_[height] = train_features[best_feature];
features_split_values_[height] = features_best_splits[best_feature].first;
const size_t first_height_num = (1 << height) - 1;
std::cout << height << " " << first_height_num <<std::endl;
const auto& best_feature_split_infos =
features_best_splits[best_feature].second.second;
for (size_t node = 0; node < best_feature_split_infos.size(); ++node) {
std::cout << node << " " << first_height_num + node << " " << best_feature_split_infos.size() <<std::endl;
nodes_values_[GetLeftChildNum(first_height_num + node)] =
best_feature_split_infos[node].left_split_value;
nodes_values_[GetRightChildNum(first_height_num + node)] =
best_feature_split_infos[node].right_split_value;
std::cout <<best_feature_split_infos[node].left_split_size << " "
<< best_feature_split_infos[node].right_split_size << std::endl;
}

vector<vector<size_t>> objects_in_nodes_next_level;
@@ -184,6 +194,10 @@ void GradientBoostingTreeOblivious::Fit(

double GradientBoostingTreeOblivious::Predict(
const vector<size_t>& test_object_features) const {
for (auto el : nodes_values_) {
std::cout << el << " ";
}
std::cout << std::endl;
size_t node_num = 0;
for (size_t h = 0; h < height_; ++h) {
if (test_object_features[features_[h]] <= features_split_values_[h]) {
@@ -3,13 +3,15 @@
#include <memory>
#include <string>
#include <vector>
#include <gradient_boosting/GradientBoosting.h>

#include "gradient_boosting/binarization/ThresholdContainer.h"
#include "gradient_boosting/binarization/ThresholdCreator.h"
#include "gradient_boosting/binarization/ThresholdCreatorByValue.h"
#include "gradient_boosting/binarization/ThresholdCreatorByStatistics.h"
#include "gradient_boosting/config/GradientBoostingConfig.h"
#include "utils/data_containers/ElementContainer.h"
#include "utils/io/SimpleCSVReader.h"

#include "third_party/ctpl/ctpl_stl.h"
#include "third_party/json/single_include/nlohmann/json.hpp"
@@ -42,9 +44,11 @@ int main(int argc, char** argv) {
json config;
in >> config;
const gradient_boosting::config::GradientBoostingConfig gb_config(config);
std::cout << "Achtung working json reading to config : "
<< gb_config.GetNumberOfStatisticsThresholds() << " "
<< gb_config.GetNumberOfValueThresholds() << std::endl;
utils::io::SimpleCSVReader reader(gb_config.GetTrainData());
const auto data = reader.ReadFile();
std::cout << data.columns() << " " << data.rows() << std::endl;
gradient_boosting::GradientBoosting gb(gb_config);
gb.TestGradientBoosting(data);
return 0;
}

@@ -73,11 +77,6 @@ void TestJSONReadPrint() {
}
};
std::cout << j2.dump(4) << std::endl;

const GradientBoostingConfig config(j2);
std::cout << config.GetNumberOfValueThresholds() << " "
<< config.GetNumberOfStatisticsThresholds() << std::endl;

}

void TestThreadPool() {
@@ -19,6 +19,7 @@ std::vector<std::string> split(const std::string &str, char token = ',') {
to_push += el;
}
}
result.push_back(to_push);
return result;
}