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
e2835654
Commit
e2835654
authored
Jan 12, 2018
by
Guolin Ke
Browse files
refine output message of loading model.
parent
1a35083a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
5 deletions
+5
-5
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+3
-1
python-package/lightgbm/engine.py
python-package/lightgbm/engine.py
+1
-1
src/application/application.cpp
src/application/application.cpp
+1
-1
src/boosting/gbdt_model_text.cpp
src/boosting/gbdt_model_text.cpp
+0
-2
No files found.
python-package/lightgbm/basic.py
View file @
e2835654
...
@@ -1651,7 +1651,7 @@ class Booster(object):
...
@@ -1651,7 +1651,7 @@ class Booster(object):
c_str
(
filename
)))
c_str
(
filename
)))
_save_pandas_categorical
(
filename
,
self
.
pandas_categorical
)
_save_pandas_categorical
(
filename
,
self
.
pandas_categorical
)
def
_load_model_from_string
(
self
,
model_str
):
def
_load_model_from_string
(
self
,
model_str
,
verbose
=
True
):
"""[Private] Load model from string"""
"""[Private] Load model from string"""
if
self
.
handle
is
not
None
:
if
self
.
handle
is
not
None
:
_safe_call
(
_LIB
.
LGBM_BoosterFree
(
self
.
handle
))
_safe_call
(
_LIB
.
LGBM_BoosterFree
(
self
.
handle
))
...
@@ -1666,6 +1666,8 @@ class Booster(object):
...
@@ -1666,6 +1666,8 @@ class Booster(object):
_safe_call
(
_LIB
.
LGBM_BoosterGetNumClasses
(
_safe_call
(
_LIB
.
LGBM_BoosterGetNumClasses
(
self
.
handle
,
self
.
handle
,
ctypes
.
byref
(
out_num_class
)))
ctypes
.
byref
(
out_num_class
)))
if
verbose
:
print
(
'Finished loading model, total used %d iterations'
%
(
int
(
out_num_iterations
.
value
)))
self
.
__num_class
=
out_num_class
.
value
self
.
__num_class
=
out_num_class
.
value
def
_save_model_to_string
(
self
,
num_iteration
=-
1
):
def
_save_model_to_string
(
self
,
num_iteration
=-
1
):
...
...
python-package/lightgbm/engine.py
View file @
e2835654
...
@@ -222,7 +222,7 @@ def train(params, train_set, num_boost_round=100,
...
@@ -222,7 +222,7 @@ def train(params, train_set, num_boost_round=100,
for
dataset_name
,
eval_name
,
score
,
_
in
evaluation_result_list
:
for
dataset_name
,
eval_name
,
score
,
_
in
evaluation_result_list
:
booster
.
best_score
[
dataset_name
][
eval_name
]
=
score
booster
.
best_score
[
dataset_name
][
eval_name
]
=
score
if
not
keep_training_booster
:
if
not
keep_training_booster
:
booster
.
_load_model_from_string
(
booster
.
_save_model_to_string
())
booster
.
_load_model_from_string
(
booster
.
_save_model_to_string
()
,
False
)
booster
.
free_dataset
()
booster
.
free_dataset
()
return
booster
return
booster
...
...
src/application/application.cpp
View file @
e2835654
...
@@ -254,7 +254,7 @@ void Application::Predict() {
...
@@ -254,7 +254,7 @@ void Application::Predict() {
void
Application
::
InitPredict
()
{
void
Application
::
InitPredict
()
{
boosting_
.
reset
(
boosting_
.
reset
(
Boosting
::
CreateBoosting
(
"gbdt"
,
config_
.
io_config
.
input_model
.
c_str
()));
Boosting
::
CreateBoosting
(
"gbdt"
,
config_
.
io_config
.
input_model
.
c_str
()));
Log
::
Info
(
"Finished initializing prediction
"
);
Log
::
Info
(
"Finished initializing prediction
, total used %d iterations"
,
boosting_
->
GetCurrentIteration
()
);
}
}
void
Application
::
ConvertModel
()
{
void
Application
::
ConvertModel
()
{
...
...
src/boosting/gbdt_model_text.cpp
View file @
e2835654
...
@@ -458,8 +458,6 @@ bool GBDT::LoadModelFromString(const char* buffer, size_t len) {
...
@@ -458,8 +458,6 @@ bool GBDT::LoadModelFromString(const char* buffer, size_t len) {
}
}
OMP_THROW_EX
();
OMP_THROW_EX
();
}
}
Log
::
Info
(
"Finished loading %d models"
,
models_
.
size
());
num_iteration_for_pred_
=
static_cast
<
int
>
(
models_
.
size
())
/
num_tree_per_iteration_
;
num_iteration_for_pred_
=
static_cast
<
int
>
(
models_
.
size
())
/
num_tree_per_iteration_
;
num_init_iteration_
=
num_iteration_for_pred_
;
num_init_iteration_
=
num_iteration_for_pred_
;
iter_
=
0
;
iter_
=
0
;
...
...
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