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
7287af3e
Commit
7287af3e
authored
Nov 26, 2016
by
Guolin Ke
Browse files
change no_limit to <=0. fix float in is_1d_list.
parent
28e891ad
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
13 deletions
+11
-13
include/LightGBM/c_api.h
include/LightGBM/c_api.h
+4
-4
include/LightGBM/config.h
include/LightGBM/config.h
+3
-3
include/LightGBM/meta.h
include/LightGBM/meta.h
+0
-1
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+1
-1
src/application/application.cpp
src/application/application.cpp
+1
-2
src/boosting/gbdt.cpp
src/boosting/gbdt.cpp
+2
-2
No files found.
include/LightGBM/c_api.h
View file @
7287af3e
...
@@ -365,7 +365,7 @@ DllExport int LGBM_BoosterGetPredict(BoosterHandle handle,
...
@@ -365,7 +365,7 @@ DllExport int LGBM_BoosterGetPredict(BoosterHandle handle,
* 0:normal, with transform (if needed)
* 0:normal, with transform (if needed)
* 1:raw score
* 1:raw score
* 2:leaf index
* 2:leaf index
* \param num_iteration number of iteration for prediction, < 0 means no limit
* \param num_iteration number of iteration for prediction, <
=
0 means no limit
* \param result_filename filename of result file
* \param result_filename filename of result file
* \return 0 when succeed, -1 when failure happens
* \return 0 when succeed, -1 when failure happens
*/
*/
...
@@ -391,7 +391,7 @@ DllExport int LGBM_BoosterPredictForFile(BoosterHandle handle,
...
@@ -391,7 +391,7 @@ DllExport int LGBM_BoosterPredictForFile(BoosterHandle handle,
* 0:normal, with transform (if needed)
* 0:normal, with transform (if needed)
* 1:raw score
* 1:raw score
* 2:leaf index
* 2:leaf index
* \param num_iteration number of iteration for prediction, < 0 means no limit
* \param num_iteration number of iteration for prediction, <
=
0 means no limit
* \param out_len len of output result
* \param out_len len of output result
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \return 0 when succeed, -1 when failure happens
* \return 0 when succeed, -1 when failure happens
...
@@ -422,7 +422,7 @@ DllExport int LGBM_BoosterPredictForCSR(BoosterHandle handle,
...
@@ -422,7 +422,7 @@ DllExport int LGBM_BoosterPredictForCSR(BoosterHandle handle,
* 0:normal, with transform (if needed)
* 0:normal, with transform (if needed)
* 1:raw score
* 1:raw score
* 2:leaf index
* 2:leaf index
* \param num_iteration number of iteration for prediction, < 0 means no limit
* \param num_iteration number of iteration for prediction, <
=
0 means no limit
* \param out_len len of output result
* \param out_len len of output result
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \return 0 when succeed, -1 when failure happens
* \return 0 when succeed, -1 when failure happens
...
@@ -441,7 +441,7 @@ DllExport int LGBM_BoosterPredictForMat(BoosterHandle handle,
...
@@ -441,7 +441,7 @@ DllExport int LGBM_BoosterPredictForMat(BoosterHandle handle,
/*!
/*!
* \brief save model into file
* \brief save model into file
* \param handle handle
* \param handle handle
* \param num_iteration, < 0 means
no limit
* \param num_iteration, <
=
0 means
save all
* \param filename file name
* \param filename file name
* \return 0 when succeed, -1 when failure happens
* \return 0 when succeed, -1 when failure happens
*/
*/
...
...
include/LightGBM/config.h
View file @
7287af3e
...
@@ -99,7 +99,7 @@ public:
...
@@ -99,7 +99,7 @@ public:
std
::
string
output_result
=
"LightGBM_predict_result.txt"
;
std
::
string
output_result
=
"LightGBM_predict_result.txt"
;
std
::
string
input_model
=
""
;
std
::
string
input_model
=
""
;
int
verbosity
=
1
;
int
verbosity
=
1
;
int
num_iteration_predict
=
NO_LIMIT
;
int
num_iteration_predict
=
-
1
;
bool
is_pre_partition
=
false
;
bool
is_pre_partition
=
false
;
bool
is_enable_sparse
=
true
;
bool
is_enable_sparse
=
true
;
bool
use_two_round_loading
=
false
;
bool
use_two_round_loading
=
false
;
...
@@ -166,12 +166,12 @@ public:
...
@@ -166,12 +166,12 @@ public:
int
feature_fraction_seed
=
2
;
int
feature_fraction_seed
=
2
;
double
feature_fraction
=
1.0
f
;
double
feature_fraction
=
1.0
f
;
// max cache size(unit:MB) for historical histogram. < 0 means not limit
// max cache size(unit:MB) for historical histogram. < 0 means not limit
double
histogram_pool_size
=
NO_LIMIT
;
double
histogram_pool_size
=
-
1.0
f
;
// max depth of tree model.
// max depth of tree model.
// Still grow tree by leaf-wise, but limit the max depth to avoid over-fitting
// Still grow tree by leaf-wise, but limit the max depth to avoid over-fitting
// And the max leaves will be min(num_leaves, pow(2, max_depth - 1))
// And the max leaves will be min(num_leaves, pow(2, max_depth - 1))
// max_depth < 0 means not limit
// max_depth < 0 means not limit
int
max_depth
=
NO_LIMIT
;
int
max_depth
=
-
1
;
void
Set
(
const
std
::
unordered_map
<
std
::
string
,
std
::
string
>&
params
)
override
;
void
Set
(
const
std
::
unordered_map
<
std
::
string
,
std
::
string
>&
params
)
override
;
};
};
...
...
include/LightGBM/meta.h
View file @
7287af3e
...
@@ -24,7 +24,6 @@ using ReduceFunction = std::function<void(const char*, char*, int)>;
...
@@ -24,7 +24,6 @@ using ReduceFunction = std::function<void(const char*, char*, int)>;
using
PredictFunction
=
using
PredictFunction
=
std
::
function
<
std
::
vector
<
double
>
(
const
std
::
vector
<
std
::
pair
<
int
,
double
>>&
)
>
;
std
::
function
<
std
::
vector
<
double
>
(
const
std
::
vector
<
std
::
pair
<
int
,
double
>>&
)
>
;
#define NO_LIMIT (-1)
#define NO_SPECIFIC (-1)
#define NO_SPECIFIC (-1)
}
// namespace LightGBM
}
// namespace LightGBM
...
...
python-package/lightgbm/basic.py
View file @
7287af3e
...
@@ -82,7 +82,7 @@ def is_1d_list(data):
...
@@ -82,7 +82,7 @@ def is_1d_list(data):
if
not
isinstance
(
data
,
list
):
if
not
isinstance
(
data
,
list
):
return
False
return
False
if
len
(
data
)
>
0
:
if
len
(
data
)
>
0
:
if
not
isinstance
(
data
[
0
],
(
int
,
str
,
bool
)
):
if
not
isinstance
(
data
[
0
],
(
int
,
float
,
bool
)
):
return
False
return
False
return
True
return
True
...
...
src/application/application.cpp
View file @
7287af3e
...
@@ -226,9 +226,8 @@ void Application::Train() {
...
@@ -226,9 +226,8 @@ void Application::Train() {
Log
::
Info
(
"%f seconds elapsed, finished iteration %d"
,
std
::
chrono
::
duration
<
double
,
Log
::
Info
(
"%f seconds elapsed, finished iteration %d"
,
std
::
chrono
::
duration
<
double
,
std
::
milli
>
(
end_time
-
start_time
)
*
1e-3
,
iter
+
1
);
std
::
milli
>
(
end_time
-
start_time
)
*
1e-3
,
iter
+
1
);
}
}
is_finished
=
true
;
// save model to file
// save model to file
boosting_
->
SaveModelToFile
(
NO_LIMIT
,
config_
.
io_config
.
output_model
.
c_str
());
boosting_
->
SaveModelToFile
(
-
1
,
config_
.
io_config
.
output_model
.
c_str
());
Log
::
Info
(
"Finished training"
);
Log
::
Info
(
"Finished training"
);
}
}
...
...
src/boosting/gbdt.cpp
View file @
7287af3e
...
@@ -414,12 +414,12 @@ void GBDT::SaveModelToFile(int num_iteration, const char* filename) const {
...
@@ -414,12 +414,12 @@ void GBDT::SaveModelToFile(int num_iteration, const char* filename) const {
output_file
<<
std
::
endl
;
output_file
<<
std
::
endl
;
int
num_used_model
=
0
;
int
num_used_model
=
0
;
if
(
num_iteration
=
=
NO_LIMIT
)
{
if
(
num_iteration
<
=
0
)
{
num_used_model
=
static_cast
<
int
>
(
models_
.
size
());
num_used_model
=
static_cast
<
int
>
(
models_
.
size
());
}
else
{
}
else
{
num_used_model
=
num_iteration
*
num_class_
;
num_used_model
=
num_iteration
*
num_class_
;
}
}
num_used_model
=
std
::
min
(
num_used_model
,
static_cast
<
int
>
(
models_
.
size
()));
// output tree models
// output tree models
for
(
int
i
=
0
;
i
<
num_used_model
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num_used_model
;
++
i
)
{
output_file
<<
"Tree="
<<
i
<<
std
::
endl
;
output_file
<<
"Tree="
<<
i
<<
std
::
endl
;
...
...
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