Unverified Commit 1e5049a1 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

fixed cpplint issues (#2756)

parent 3670e476
...@@ -333,7 +333,6 @@ class FeatureGroup { ...@@ -333,7 +333,6 @@ class FeatureGroup {
} }
private: private:
void CreateBinData(int num_data, bool is_multi_val, bool force_dense, bool force_sparse) { void CreateBinData(int num_data, bool is_multi_val, bool force_dense, bool force_sparse) {
if (is_multi_val) { if (is_multi_val) {
multi_bin_data_.clear(); multi_bin_data_.clear();
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "split_info.hpp"
#include "monotone_constraints.hpp" #include "monotone_constraints.hpp"
#include "split_info.hpp"
namespace LightGBM { namespace LightGBM {
...@@ -59,11 +59,11 @@ class FeatureHistogram { ...@@ -59,11 +59,11 @@ class FeatureHistogram {
meta_ = meta; meta_ = meta;
data_ = data; data_ = data;
if (meta_->bin_type == BinType::NumericalBin) { if (meta_->bin_type == BinType::NumericalBin) {
find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdNumerical, this, std::placeholders::_1 find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdNumerical, this, std::placeholders::_1,
, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5); std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
} else { } else {
find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdCategorical, this, std::placeholders::_1 find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdCategorical, this, std::placeholders::_1,
, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5); std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
} }
rand_ = Random(meta_->config->extra_seed); rand_ = Random(meta_->config->extra_seed);
} }
...@@ -495,9 +495,9 @@ class FeatureHistogram { ...@@ -495,9 +495,9 @@ class FeatureHistogram {
* \param sum_hessians * \param sum_hessians
* \return leaf output * \return leaf output
*/ */
static double static double CalculateSplittedLeafOutput(double sum_gradients, double sum_hessians,
CalculateSplittedLeafOutput(double sum_gradients, double sum_hessians, double l1, double l2, double max_delta_step,
double l1, double l2, double max_delta_step, const ConstraintEntry& constraints) { const ConstraintEntry& constraints) {
double ret = CalculateSplittedLeafOutput(sum_gradients, sum_hessians, l1, l2, max_delta_step); double ret = CalculateSplittedLeafOutput(sum_gradients, sum_hessians, l1, l2, max_delta_step);
if (ret < constraints.min) { if (ret < constraints.min) {
ret = constraints.min; ret = constraints.min;
...@@ -680,10 +680,10 @@ class FeatureHistogram { ...@@ -680,10 +680,10 @@ class FeatureHistogram {
/*! \brief random number generator for extremely randomized trees */ /*! \brief random number generator for extremely randomized trees */
Random rand_; Random rand_;
std::function<void(double, double, data_size_t, const ConstraintEntry&, std::function<void(double, double, data_size_t, const ConstraintEntry&, SplitInfo*)>
SplitInfo*)> find_best_threshold_fun_;
find_best_threshold_fun_;
}; };
class HistogramPool { class HistogramPool {
public: public:
/*! /*!
......
#ifndef LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_H_ /*!
#define LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_H_ * Copyright (c) 2020 Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*/
#ifndef LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_HPP_
#define LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_HPP_
#include <limits>
#include <algorithm> #include <algorithm>
#include <vector>
#include <cstdint> #include <cstdint>
#include <limits> #include <vector>
namespace LightGBM { namespace LightGBM {
...@@ -12,7 +16,7 @@ struct ConstraintEntry { ...@@ -12,7 +16,7 @@ struct ConstraintEntry {
double min = -std::numeric_limits<double>::max(); double min = -std::numeric_limits<double>::max();
double max = std::numeric_limits<double>::max(); double max = std::numeric_limits<double>::max();
ConstraintEntry(){}; ConstraintEntry() {}
void Reset() { void Reset() {
min = -std::numeric_limits<double>::max(); min = -std::numeric_limits<double>::max();
...@@ -22,20 +26,21 @@ struct ConstraintEntry { ...@@ -22,20 +26,21 @@ struct ConstraintEntry {
void UpdateMin(double new_min) { min = std::max(new_min, min); } void UpdateMin(double new_min) { min = std::max(new_min, min); }
void UpdateMax(double new_max) { max = std::min(new_max, max); } void UpdateMax(double new_max) { max = std::min(new_max, max); }
}; };
template <typename ConstraintEntry> template <typename ConstraintEntry>
class LeafConstraints { class LeafConstraints {
public: public:
LeafConstraints(int num_leaves) : num_leaves_(num_leaves) { explicit LeafConstraints(int num_leaves) : num_leaves_(num_leaves) {
entries_.resize(num_leaves_); entries_.resize(num_leaves_);
} }
void Reset() { void Reset() {
for (auto& entry : entries_) { for (auto& entry : entries_) {
entry.Reset(); entry.Reset();
} }
} }
void UpdateConstraints(bool is_numerical_split, int leaf, int new_leaf, void UpdateConstraints(bool is_numerical_split, int leaf, int new_leaf,
int8_t monotone_type, double right_output, int8_t monotone_type, double right_output,
double left_output) { double left_output) {
...@@ -59,5 +64,5 @@ class LeafConstraints { ...@@ -59,5 +64,5 @@ class LeafConstraints {
std::vector<ConstraintEntry> entries_; std::vector<ConstraintEntry> entries_;
}; };
} // namespace LightGBM } // namespace LightGBM
#endif // LightGBM_TREELEARNER_MONOTONE_CONSTRAINTS_H_ #endif // LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_HPP_
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "data_partition.hpp" #include "data_partition.hpp"
#include "feature_histogram.hpp" #include "feature_histogram.hpp"
#include "leaf_splits.hpp" #include "leaf_splits.hpp"
#include "split_info.hpp"
#include "monotone_constraints.hpp" #include "monotone_constraints.hpp"
#include "split_info.hpp"
#ifdef USE_GPU #ifdef USE_GPU
// Use 4KBytes aligned allocator for ordered gradients and ordered hessians when GPU is enabled. // Use 4KBytes aligned allocator for ordered gradients and ordered hessians when GPU is enabled.
...@@ -158,7 +158,7 @@ class SerialTreeLearner: public TreeLearner { ...@@ -158,7 +158,7 @@ class SerialTreeLearner: public TreeLearner {
std::vector<SplitInfo> best_split_per_leaf_; std::vector<SplitInfo> best_split_per_leaf_;
/*! \brief store best split per feature for all leaves */ /*! \brief store best split per feature for all leaves */
std::vector<SplitInfo> splits_per_leaf_; std::vector<SplitInfo> splits_per_leaf_;
// Stores minimum and maximum constraints for each leaf /*! \brief stores minimum and maximum constraints for each leaf */
std::unique_ptr<LeafConstraints<ConstraintEntry>> constraints_; std::unique_ptr<LeafConstraints<ConstraintEntry>> constraints_;
/*! \brief stores best thresholds for all feature for smaller leaf */ /*! \brief stores best thresholds for all feature for smaller leaf */
......
...@@ -399,7 +399,6 @@ void VotingParallelTreeLearner<TREELEARNER_T>::FindBestSplitsFromHistograms(cons ...@@ -399,7 +399,6 @@ void VotingParallelTreeLearner<TREELEARNER_T>::FindBestSplitsFromHistograms(cons
} }
if (larger_is_feature_aggregated_[feature_index]) { if (larger_is_feature_aggregated_[feature_index]) {
// restore from buffer // restore from buffer
larger_leaf_histogram_array_global_[feature_index].FromMemory(output_buffer_.data() + larger_buffer_read_start_pos_[feature_index]); larger_leaf_histogram_array_global_[feature_index].FromMemory(output_buffer_.data() + larger_buffer_read_start_pos_[feature_index]);
...@@ -409,7 +408,7 @@ void VotingParallelTreeLearner<TREELEARNER_T>::FindBestSplitsFromHistograms(cons ...@@ -409,7 +408,7 @@ void VotingParallelTreeLearner<TREELEARNER_T>::FindBestSplitsFromHistograms(cons
this->ComputeBestSplitForFeature( this->ComputeBestSplitForFeature(
larger_leaf_histogram_array_global_.get(), feature_index, larger_leaf_histogram_array_global_.get(), feature_index,
real_feature_index, real_feature_index,
larger_node_used_features[feature_index], larger_node_used_features[feature_index],
GetGlobalDataCountInLeaf(larger_leaf_splits_global_->leaf_index()), GetGlobalDataCountInLeaf(larger_leaf_splits_global_->leaf_index()),
larger_leaf_splits_global_.get(), larger_leaf_splits_global_.get(),
......
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