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
532722b9
Unverified
Commit
532722b9
authored
Mar 06, 2020
by
Nikita Titov
Committed by
GitHub
Mar 06, 2020
Browse files
fixed cpplint errors and VS project files (#2873)
parent
67d56b26
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
29 deletions
+60
-29
include/LightGBM/tree_learner.h
include/LightGBM/tree_learner.h
+1
-3
src/boosting/gbdt.h
src/boosting/gbdt.h
+1
-1
src/io/dataset_loader.cpp
src/io/dataset_loader.cpp
+1
-2
src/treelearner/col_sampler.hpp
src/treelearner/col_sampler.hpp
+4
-2
src/treelearner/feature_histogram.hpp
src/treelearner/feature_histogram.hpp
+47
-19
src/treelearner/serial_tree_learner.cpp
src/treelearner/serial_tree_learner.cpp
+2
-2
windows/LightGBM.vcxproj
windows/LightGBM.vcxproj
+1
-0
windows/LightGBM.vcxproj.filters
windows/LightGBM.vcxproj.filters
+3
-0
No files found.
include/LightGBM/tree_learner.h
View file @
532722b9
...
...
@@ -7,12 +7,11 @@
#include <LightGBM/config.h>
#include <LightGBM/meta.h>
#include <LightGBM/utils/json11.h>
#include <string>
#include <vector>
#include <LightGBM/utils/json11.h>
namespace
LightGBM
{
using
json11
::
Json
;
...
...
@@ -54,7 +53,6 @@ class TreeLearner {
* \brief training tree model on dataset
* \param gradients The first order gradients
* \param hessians The second order gradients
* \param is_constant_hessian True if all hessians share the same value
* \return A trained tree
*/
virtual
Tree
*
Train
(
const
score_t
*
gradients
,
const
score_t
*
hessians
)
=
0
;
...
...
src/boosting/gbdt.h
View file @
532722b9
...
...
@@ -8,6 +8,7 @@
#include <LightGBM/boosting.h>
#include <LightGBM/objective_function.h>
#include <LightGBM/prediction_early_stop.h>
#include <LightGBM/utils/json11.h>
#include <LightGBM/utils/threading.h>
#include <string>
...
...
@@ -21,7 +22,6 @@
#include <utility>
#include <vector>
#include <LightGBM/utils/json11.h>
#include "score_updater.hpp"
namespace
LightGBM
{
...
...
src/io/dataset_loader.cpp
View file @
532722b9
...
...
@@ -6,13 +6,12 @@
#include <LightGBM/network.h>
#include <LightGBM/utils/array_args.h>
#include <LightGBM/utils/json11.h>
#include <LightGBM/utils/log.h>
#include <LightGBM/utils/openmp_wrapper.h>
#include <fstream>
#include <LightGBM/utils/json11.h>
namespace
LightGBM
{
using
json11
::
Json
;
...
...
src/treelearner/col_sampler.hpp
View file @
532722b9
...
...
@@ -8,15 +8,17 @@
#include <LightGBM/dataset.h>
#include <LightGBM/meta.h>
#include <LightGBM/utils/common.h>
#include <LightGBM/utils/openmp_wrapper.h>
#include <LightGBM/utils/random.h>
#include <algorithm>
#include <vector>
namespace
LightGBM
{
class
ColSampler
{
public:
ColSampler
(
const
Config
*
config
)
explicit
ColSampler
(
const
Config
*
config
)
:
fraction_bytree_
(
config
->
feature_fraction
),
fraction_bynode_
(
config
->
feature_fraction_bynode
),
seed_
(
config
->
feature_fraction_seed
),
...
...
src/treelearner/feature_histogram.hpp
View file @
532722b9
...
...
@@ -35,7 +35,6 @@ class FeatureMetainfo {
BinType
bin_type
;
/*! \brief random number generator for extremely randomized trees */
mutable
Random
rand
;
;
};
/*!
* \brief FeatureHistogram is used to construct and store a histogram for a
...
...
@@ -68,6 +67,7 @@ class FeatureHistogram {
}
hist_t
*
RawData
()
{
return
data_
;
}
/*!
* \brief Subtract current histograms with other
* \param other The histogram that want to subtract
...
...
@@ -300,16 +300,20 @@ class FeatureHistogram {
static_cast
<
data_size_t
>
(
Common
::
RoundInt
(
hess
*
cnt_factor
));
// if data not enough, or sum hessian too small
if
(
cnt
<
meta_
->
config
->
min_data_in_leaf
||
hess
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
hess
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
continue
;
}
data_size_t
other_count
=
num_data
-
cnt
;
// if data not enough
if
(
other_count
<
meta_
->
config
->
min_data_in_leaf
)
continue
;
if
(
other_count
<
meta_
->
config
->
min_data_in_leaf
)
{
continue
;
}
double
sum_other_hessian
=
sum_hessian
-
hess
-
kEpsilon
;
// if sum hessian too small
if
(
sum_other_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
if
(
sum_other_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
continue
;
}
double
sum_other_gradient
=
sum_gradient
-
grad
;
if
(
USE_RAND
)
{
...
...
@@ -323,7 +327,9 @@ class FeatureHistogram {
meta_
->
config
->
lambda_l1
,
l2
,
meta_
->
config
->
max_delta_step
,
constraints
,
0
);
// gain with split is worse than without split
if
(
current_gain
<=
min_gain_shift
)
continue
;
if
(
current_gain
<=
min_gain_shift
)
{
continue
;
}
// mark to is splittable
is_splittable_
=
true
;
...
...
@@ -392,17 +398,23 @@ class FeatureHistogram {
cnt_cur_group
+=
cnt
;
if
(
left_count
<
meta_
->
config
->
min_data_in_leaf
||
sum_left_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
sum_left_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
continue
;
}
data_size_t
right_count
=
num_data
-
left_count
;
if
(
right_count
<
meta_
->
config
->
min_data_in_leaf
||
right_count
<
min_data_per_group
)
right_count
<
min_data_per_group
)
{
break
;
}
double
sum_right_hessian
=
sum_hessian
-
sum_left_hessian
;
if
(
sum_right_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
break
;
if
(
sum_right_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
break
;
}
if
(
cnt_cur_group
<
min_data_per_group
)
continue
;
if
(
cnt_cur_group
<
min_data_per_group
)
{
continue
;
}
cnt_cur_group
=
0
;
...
...
@@ -416,7 +428,9 @@ class FeatureHistogram {
sum_left_gradient
,
sum_left_hessian
,
sum_right_gradient
,
sum_right_hessian
,
meta_
->
config
->
lambda_l1
,
l2
,
meta_
->
config
->
max_delta_step
,
constraints
,
0
);
if
(
current_gain
<=
min_gain_shift
)
continue
;
if
(
current_gain
<=
min_gain_shift
)
{
continue
;
}
is_splittable_
=
true
;
if
(
current_gain
>
best_gain
)
{
best_left_count
=
left_count
;
...
...
@@ -546,7 +560,7 @@ class FeatureHistogram {
if
(
std
::
isnan
(
current_gain
)
||
current_gain
<=
min_gain_shift
)
{
output
->
gain
=
kMinScore
;
Log
::
Warning
(
"'Forced Split' will be ignored since the gain getting worse.
"
);
"'Forced Split' will be ignored since the gain getting worse."
);
return
;
}
...
...
@@ -806,15 +820,20 @@ class FeatureHistogram {
right_count
+=
cnt
;
// if data not enough, or sum hessian too small
if
(
right_count
<
meta_
->
config
->
min_data_in_leaf
||
sum_right_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
sum_right_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
continue
;
}
data_size_t
left_count
=
num_data
-
right_count
;
// if data not enough
if
(
left_count
<
meta_
->
config
->
min_data_in_leaf
)
break
;
if
(
left_count
<
meta_
->
config
->
min_data_in_leaf
)
{
break
;
}
double
sum_left_hessian
=
sum_hessian
-
sum_right_hessian
;
// if sum hessian too small
if
(
sum_left_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
break
;
if
(
sum_left_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
break
;
}
double
sum_left_gradient
=
sum_gradient
-
sum_right_gradient
;
if
(
USE_RAND
)
{
...
...
@@ -829,7 +848,9 @@ class FeatureHistogram {
meta_
->
config
->
lambda_l2
,
meta_
->
config
->
max_delta_step
,
constraints
,
meta_
->
monotone_type
);
// gain with split is worse than without split
if
(
current_gain
<=
min_gain_shift
)
continue
;
if
(
current_gain
<=
min_gain_shift
)
{
continue
;
}
// mark to is splittable
is_splittable_
=
true
;
...
...
@@ -883,15 +904,20 @@ class FeatureHistogram {
}
// if data not enough, or sum hessian too small
if
(
left_count
<
meta_
->
config
->
min_data_in_leaf
||
sum_left_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
sum_left_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
continue
;
}
data_size_t
right_count
=
num_data
-
left_count
;
// if data not enough
if
(
right_count
<
meta_
->
config
->
min_data_in_leaf
)
break
;
if
(
right_count
<
meta_
->
config
->
min_data_in_leaf
)
{
break
;
}
double
sum_right_hessian
=
sum_hessian
-
sum_left_hessian
;
// if sum hessian too small
if
(
sum_right_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
break
;
if
(
sum_right_hessian
<
meta_
->
config
->
min_sum_hessian_in_leaf
)
{
break
;
}
double
sum_right_gradient
=
sum_gradient
-
sum_left_gradient
;
if
(
USE_RAND
)
{
...
...
@@ -906,7 +932,9 @@ class FeatureHistogram {
meta_
->
config
->
lambda_l2
,
meta_
->
config
->
max_delta_step
,
constraints
,
meta_
->
monotone_type
);
// gain with split is worse than without split
if
(
current_gain
<=
min_gain_shift
)
continue
;
if
(
current_gain
<=
min_gain_shift
)
{
continue
;
}
// mark to is splittable
is_splittable_
=
true
;
...
...
src/treelearner/serial_tree_learner.cpp
View file @
532722b9
...
...
@@ -177,7 +177,7 @@ Tree* SerialTreeLearner::Train(const score_t* gradients, const score_t *hessians
if
(
BeforeFindBestSplit
(
tree_prt
,
left_leaf
,
right_leaf
))
{
// find best threshold for every feature
FindBestSplits
();
}
}
// Get a leaf with max split gain
int
best_leaf
=
static_cast
<
int
>
(
ArrayArgs
<
SplitInfo
>::
ArgMax
(
best_split_per_leaf_
));
// Get split information for best leaf
...
...
@@ -515,7 +515,7 @@ int32_t SerialTreeLearner::ForceSplits(Tree* tree, int* left_leaf,
}
Split
(
tree
,
best_leaf
,
left_leaf
,
right_leaf
);
*
(
cur_depth
)
=
std
::
max
(
*
(
cur_depth
),
tree
->
leaf_depth
(
*
left_leaf
));
result_count
++
;
++
result_count
;
}
return
result_count
;
}
...
...
windows/LightGBM.vcxproj
View file @
532722b9
...
...
@@ -281,6 +281,7 @@
<ClInclude
Include=
"..\src\objective\regression_objective.hpp"
/>
<ClInclude
Include=
"..\src\objective\multiclass_objective.hpp"
/>
<ClInclude
Include=
"..\src\objective\xentropy_objective.hpp"
/>
<ClInclude
Include=
"..\src\treelearner\col_sampler.hpp"
/>
<ClInclude
Include=
"..\src\treelearner\cost_effective_gradient_boosting.hpp"
/>
<ClInclude
Include=
"..\src\treelearner\data_partition.hpp"
/>
<ClInclude
Include=
"..\src\treelearner\feature_histogram.hpp"
/>
...
...
windows/LightGBM.vcxproj.filters
View file @
532722b9
...
...
@@ -213,6 +213,9 @@
<ClInclude
Include=
"..\include\LightGBM\utils\json11.h"
>
<Filter>
include\LightGBM\utils
</Filter>
</ClInclude>
<ClInclude
Include=
"..\src\treelearner\col_sampler.hpp"
>
<Filter>
src\treelearner
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"..\src\application\application.cpp"
>
...
...
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