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
a4c022a7
"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "d563aff9a6e9f42db5d5badea6fcc35190aa6a69"
Commit
a4c022a7
authored
Feb 24, 2017
by
Guolin Ke
Browse files
fix #287
parent
ae7bbb6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletion
+33
-1
include/LightGBM/bin.h
include/LightGBM/bin.h
+2
-1
include/LightGBM/dataset.h
include/LightGBM/dataset.h
+14
-0
src/boosting/gbdt.cpp
src/boosting/gbdt.cpp
+16
-0
src/boosting/gbdt.h
src/boosting/gbdt.h
+1
-0
No files found.
include/LightGBM/bin.h
View file @
a4c022a7
...
...
@@ -136,7 +136,8 @@ public:
*/
inline
std
::
string
bin_info
()
const
{
std
::
stringstream
str_buf
;
str_buf
<<
'['
<<
min_val_
<<
','
<<
max_val_
<<
']'
;
str_buf
<<
std
::
setprecision
(
std
::
numeric_limits
<
double
>::
digits10
+
2
);
str_buf
<<
'['
<<
min_val_
<<
':'
<<
max_val_
<<
']'
;
return
str_buf
.
str
();
}
...
...
include/LightGBM/dataset.h
View file @
a4c022a7
...
...
@@ -471,6 +471,20 @@ public:
feature_names_
=
std
::
vector
<
std
::
string
>
(
feature_names
);
}
inline
std
::
vector
<
std
::
string
>
feature_infos
()
const
{
std
::
vector
<
std
::
string
>
bufs
;
for
(
int
i
=
0
;
i
<
num_total_features_
;
i
++
)
{
int
fidx
=
used_feature_map_
[
i
];
if
(
fidx
==
-
1
)
{
bufs
.
push_back
(
"none"
);
}
else
{
const
auto
bin_mapper
=
FeatureBinMapper
(
fidx
);
bufs
.
push_back
(
bin_mapper
->
bin_info
());
}
}
return
bufs
;
}
/*! \brief Get Number of data */
inline
data_size_t
num_data
()
const
{
return
num_data_
;
}
...
...
src/boosting/gbdt.cpp
View file @
a4c022a7
...
...
@@ -104,6 +104,8 @@ void GBDT::ResetTrainingData(const BoostingConfig* config, const Dataset* train_
label_idx_
=
train_data
->
label_idx
();
// get feature names
feature_names_
=
train_data
->
feature_names
();
feature_infos_
=
train_data
->
feature_infos
();
}
if
((
train_data_
!=
train_data
&&
train_data
!=
nullptr
)
...
...
@@ -558,6 +560,8 @@ std::string GBDT::SaveModelToString(int num_iterations) const {
ss
<<
"feature_names="
<<
Common
::
Join
(
feature_names_
,
" "
)
<<
std
::
endl
;
ss
<<
"feature_infos="
<<
Common
::
Join
(
feature_infos_
,
" "
)
<<
std
::
endl
;
ss
<<
std
::
endl
;
int
num_used_model
=
static_cast
<
int
>
(
models_
.
size
());
if
(
num_iterations
>
0
)
{
...
...
@@ -640,6 +644,18 @@ bool GBDT::LoadModelFromString(const std::string& model_str) {
return
false
;
}
line
=
Common
::
FindFromLines
(
lines
,
"feature_infos="
);
if
(
line
.
size
()
>
0
)
{
feature_infos_
=
Common
::
Split
(
line
.
substr
(
std
::
strlen
(
"feature_infos="
)).
c_str
(),
" "
);
if
(
feature_infos_
.
size
()
!=
static_cast
<
size_t
>
(
max_feature_idx_
+
1
))
{
Log
::
Fatal
(
"Wrong size of feature_infos"
);
return
false
;
}
}
else
{
Log
::
Fatal
(
"Model file doesn't contain feature infos"
);
return
false
;
}
// get tree models
size_t
i
=
0
;
while
(
i
<
lines
.
size
())
{
...
...
src/boosting/gbdt.h
View file @
a4c022a7
...
...
@@ -329,6 +329,7 @@ protected:
int
num_init_iteration_
;
/*! \brief Feature names */
std
::
vector
<
std
::
string
>
feature_names_
;
std
::
vector
<
std
::
string
>
feature_infos_
;
/*! \brief number of threads */
int
num_threads_
;
/*! \brief Buffer for multi-threading bagging */
...
...
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