Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
1e5049a1
Unverified
Commit
1e5049a1
authored
Feb 12, 2020
by
Nikita Titov
Committed by
GitHub
Feb 12, 2020
Browse files
fixed cpplint issues (#2756)
parent
3670e476
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
25 deletions
+28
-25
include/LightGBM/feature_group.h
include/LightGBM/feature_group.h
+0
-1
src/treelearner/feature_histogram.hpp
src/treelearner/feature_histogram.hpp
+11
-11
src/treelearner/monotone_constraints.hpp
src/treelearner/monotone_constraints.hpp
+14
-9
src/treelearner/serial_tree_learner.h
src/treelearner/serial_tree_learner.h
+2
-2
src/treelearner/voting_parallel_tree_learner.cpp
src/treelearner/voting_parallel_tree_learner.cpp
+1
-2
No files found.
include/LightGBM/feature_group.h
View file @
1e5049a1
...
...
@@ -333,7 +333,6 @@ class FeatureGroup {
}
private:
void
CreateBinData
(
int
num_data
,
bool
is_multi_val
,
bool
force_dense
,
bool
force_sparse
)
{
if
(
is_multi_val
)
{
multi_bin_data_
.
clear
();
...
...
src/treelearner/feature_histogram.hpp
View file @
1e5049a1
...
...
@@ -16,8 +16,8 @@
#include <utility>
#include <vector>
#include "split_info.hpp"
#include "monotone_constraints.hpp"
#include "split_info.hpp"
namespace
LightGBM
{
...
...
@@ -59,11 +59,11 @@ class FeatureHistogram {
meta_
=
meta
;
data_
=
data
;
if
(
meta_
->
bin_type
==
BinType
::
NumericalBin
)
{
find_best_threshold_fun_
=
std
::
bind
(
&
FeatureHistogram
::
FindBestThresholdNumerical
,
this
,
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
,
std
::
placeholders
::
_3
,
std
::
placeholders
::
_4
,
std
::
placeholders
::
_5
);
find_best_threshold_fun_
=
std
::
bind
(
&
FeatureHistogram
::
FindBestThresholdNumerical
,
this
,
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
,
std
::
placeholders
::
_3
,
std
::
placeholders
::
_4
,
std
::
placeholders
::
_5
);
}
else
{
find_best_threshold_fun_
=
std
::
bind
(
&
FeatureHistogram
::
FindBestThresholdCategorical
,
this
,
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
,
std
::
placeholders
::
_3
,
std
::
placeholders
::
_4
,
std
::
placeholders
::
_5
);
find_best_threshold_fun_
=
std
::
bind
(
&
FeatureHistogram
::
FindBestThresholdCategorical
,
this
,
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
,
std
::
placeholders
::
_3
,
std
::
placeholders
::
_4
,
std
::
placeholders
::
_5
);
}
rand_
=
Random
(
meta_
->
config
->
extra_seed
);
}
...
...
@@ -495,9 +495,9 @@ class FeatureHistogram {
* \param sum_hessians
* \return leaf output
*/
static
double
CalculateSplittedLeafOutput
(
double
sum_gradients
,
double
sum_hessians
,
double
l1
,
double
l2
,
double
max_delta_step
,
const
ConstraintEntry
&
constraints
)
{
static
double
CalculateSplittedLeafOutput
(
double
sum_gradients
,
double
sum_hessians
,
double
l1
,
double
l2
,
double
max_delta_step
,
const
ConstraintEntry
&
constraints
)
{
double
ret
=
CalculateSplittedLeafOutput
(
sum_gradients
,
sum_hessians
,
l1
,
l2
,
max_delta_step
);
if
(
ret
<
constraints
.
min
)
{
ret
=
constraints
.
min
;
...
...
@@ -680,10 +680,10 @@ class FeatureHistogram {
/*! \brief random number generator for extremely randomized trees */
Random
rand_
;
std
::
function
<
void
(
double
,
double
,
data_size_t
,
const
ConstraintEntry
&
,
SplitInfo
*
)
>
find_best_threshold_fun_
;
std
::
function
<
void
(
double
,
double
,
data_size_t
,
const
ConstraintEntry
&
,
SplitInfo
*
)
>
find_best_threshold_fun_
;
};
class
HistogramPool
{
public:
/*!
...
...
src/treelearner/monotone_constraints.hpp
View file @
1e5049a1
#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 <vector>
#include <cstdint>
#include <
limits
>
#include <
vector
>
namespace
LightGBM
{
...
...
@@ -12,7 +16,7 @@ struct ConstraintEntry {
double
min
=
-
std
::
numeric_limits
<
double
>::
max
();
double
max
=
std
::
numeric_limits
<
double
>::
max
();
ConstraintEntry
(){}
;
ConstraintEntry
()
{}
void
Reset
()
{
min
=
-
std
::
numeric_limits
<
double
>::
max
();
...
...
@@ -22,20 +26,21 @@ struct ConstraintEntry {
void
UpdateMin
(
double
new_min
)
{
min
=
std
::
max
(
new_min
,
min
);
}
void
UpdateMax
(
double
new_max
)
{
max
=
std
::
min
(
new_max
,
max
);
}
};
template
<
typename
ConstraintEntry
>
class
LeafConstraints
{
public:
LeafConstraints
(
int
num_leaves
)
:
num_leaves_
(
num_leaves
)
{
explicit
LeafConstraints
(
int
num_leaves
)
:
num_leaves_
(
num_leaves
)
{
entries_
.
resize
(
num_leaves_
);
}
void
Reset
()
{
for
(
auto
&
entry
:
entries_
)
{
entry
.
Reset
();
}
}
void
UpdateConstraints
(
bool
is_numerical_split
,
int
leaf
,
int
new_leaf
,
int8_t
monotone_type
,
double
right_output
,
double
left_output
)
{
...
...
@@ -59,5 +64,5 @@ class LeafConstraints {
std
::
vector
<
ConstraintEntry
>
entries_
;
};
}
// namespace LightGBM
#endif // L
ight
GBM_TREELEARNER_MONOTONE_CONSTRAINTS_H_
}
// namespace LightGBM
#endif
// L
IGHT
GBM_TREELEARNER_MONOTONE_CONSTRAINTS_H
PP
_
src/treelearner/serial_tree_learner.h
View file @
1e5049a1
...
...
@@ -21,8 +21,8 @@
#include "data_partition.hpp"
#include "feature_histogram.hpp"
#include "leaf_splits.hpp"
#include "split_info.hpp"
#include "monotone_constraints.hpp"
#include "split_info.hpp"
#ifdef USE_GPU
// Use 4KBytes aligned allocator for ordered gradients and ordered hessians when GPU is enabled.
...
...
@@ -158,7 +158,7 @@ class SerialTreeLearner: public TreeLearner {
std
::
vector
<
SplitInfo
>
best_split_per_leaf_
;
/*! \brief store best split per feature for all leaves */
std
::
vector
<
SplitInfo
>
splits_per_leaf_
;
/
/ S
tores minimum and maximum constraints for each leaf
/
*! \brief s
tores minimum and maximum constraints for each leaf
*/
std
::
unique_ptr
<
LeafConstraints
<
ConstraintEntry
>>
constraints_
;
/*! \brief stores best thresholds for all feature for smaller leaf */
...
...
src/treelearner/voting_parallel_tree_learner.cpp
View file @
1e5049a1
...
...
@@ -399,7 +399,6 @@ void VotingParallelTreeLearner<TREELEARNER_T>::FindBestSplitsFromHistograms(cons
}
if
(
larger_is_feature_aggregated_
[
feature_index
])
{
// restore from buffer
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
this
->
ComputeBestSplitForFeature
(
larger_leaf_histogram_array_global_
.
get
(),
feature_index
,
real_feature_index
,
real_feature_index
,
larger_node_used_features
[
feature_index
],
GetGlobalDataCountInLeaf
(
larger_leaf_splits_global_
->
leaf_index
()),
larger_leaf_splits_global_
.
get
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment