Commit 804d3ada authored by Guolin Ke's avatar Guolin Ke
Browse files

clean code.

parent df78bb3c
......@@ -94,7 +94,6 @@ public:
std::string input_model = "";
std::string input_init_score = "";
int verbosity = 1;
std::string log_file = "";
int num_model_predict = -1;
bool is_pre_partition = false;
bool is_enable_sparse = true;
......
......@@ -5,6 +5,7 @@
#include <LightGBM/utils/log.h>
#include <cstring>
#include <functional>
namespace LightGBM {
......@@ -66,12 +67,13 @@ public:
}
/*!
* \brief Set data for the pool for specific index
* \param idx which index want to set to
* \param data
* \brief Fill the pool
* \param obj_create_fun that used to generate object
*/
void Set(int idx, const T& data) {
pool_[idx] = data;
void Fill(std::function<T()> obj_create_fun) {
for (int i = 0; i < cache_size_; ++i) {
pool_[i] = obj_create_fun();
}
}
/*!
......
......@@ -159,7 +159,6 @@ void IOConfig::Set(const std::unordered_map<std::string, std::string>& params) {
GetString(params, "input_model", &input_model);
GetString(params, "output_result", &output_result);
GetString(params, "input_init_score", &input_init_score);
GetString(params, "log_file", &log_file);
std::string tmp_str = "";
if (GetString(params, "valid_data", &tmp_str)) {
valid_data_filenames = Common::Split(tmp_str.c_str(), ',');
......
......@@ -63,16 +63,17 @@ void SerialTreeLearner::Init(const Dataset* train_data) {
max_cache_size = Common::Min(max_cache_size, num_leaves_);
histogram_pool_.ResetSize(max_cache_size, num_leaves_);
for (int i = 0; i < max_cache_size; ++i) {
auto histogram_create_function = [this]() {
FeatureHistogram* tmp_histogram_array = new FeatureHistogram[train_data_->num_features()];
for (int j = 0; j < train_data_->num_features(); ++j) {
tmp_histogram_array[j].Init(train_data_->FeatureAt(j),
j, min_num_data_one_leaf_,
min_sum_hessian_one_leaf_);
j, min_num_data_one_leaf_,
min_sum_hessian_one_leaf_);
}
// set data at i-th position
histogram_pool_.Set(i, tmp_histogram_array);
}
return tmp_histogram_array;
};
histogram_pool_.Fill(histogram_create_function);
// push split information for all leaves
for (int i = 0; i < num_leaves_; ++i) {
best_split_per_leaf_.push_back(SplitInfo());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment