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
2af0dccd
Commit
2af0dccd
authored
Oct 28, 2016
by
Guolin Ke
Browse files
use real feature index in feature importance.
parent
c45d1d99
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
include/LightGBM/tree.h
include/LightGBM/tree.h
+1
-1
src/boosting/gbdt.cpp
src/boosting/gbdt.cpp
+2
-2
No files found.
include/LightGBM/tree.h
View file @
2af0dccd
...
@@ -84,7 +84,7 @@ public:
...
@@ -84,7 +84,7 @@ public:
inline
int
leaf_depth
(
int
leaf_idx
)
const
{
return
leaf_depth_
[
leaf_idx
];
}
inline
int
leaf_depth
(
int
leaf_idx
)
const
{
return
leaf_depth_
[
leaf_idx
];
}
/*! \brief Get feature of specific split*/
/*! \brief Get feature of specific split*/
inline
int
split_feature
(
int
split_idx
)
const
{
return
split_feature_
[
split_idx
];
}
inline
int
split_feature
_real
(
int
split_idx
)
const
{
return
split_feature_
real_
[
split_idx
];
}
/*!
/*!
* \brief Shrinkage for the tree's output
* \brief Shrinkage for the tree's output
...
...
src/boosting/gbdt.cpp
View file @
2af0dccd
...
@@ -223,7 +223,7 @@ void GBDT::Train() {
...
@@ -223,7 +223,7 @@ void GBDT::Train() {
}
}
fflush
(
output_model_file
);
fflush
(
output_model_file
);
}
}
FeatureImportance
(
models_
.
size
());
FeatureImportance
(
static_cast
<
int
>
(
models_
.
size
())
)
;
fclose
(
output_model_file
);
fclose
(
output_model_file
);
}
}
...
@@ -355,7 +355,7 @@ void GBDT::FeatureImportance(const int last_iter) {
...
@@ -355,7 +355,7 @@ void GBDT::FeatureImportance(const int last_iter) {
size_t
*
feature_importances
=
new
size_t
[
max_feature_idx_
+
1
]{
0
};
size_t
*
feature_importances
=
new
size_t
[
max_feature_idx_
+
1
]{
0
};
for
(
int
iter
=
0
;
iter
<
last_iter
;
++
iter
)
{
for
(
int
iter
=
0
;
iter
<
last_iter
;
++
iter
)
{
for
(
int
split_idx
=
0
;
split_idx
<
models_
.
at
(
iter
)
->
num_leaves
()
-
1
;
++
split_idx
)
{
for
(
int
split_idx
=
0
;
split_idx
<
models_
.
at
(
iter
)
->
num_leaves
()
-
1
;
++
split_idx
)
{
++
feature_importances
[
models_
.
at
(
iter
)
->
split_feature
(
split_idx
)];
++
feature_importances
[
models_
.
at
(
iter
)
->
split_feature
_real
(
split_idx
)];
}
}
}
}
std
::
string
ret
=
Common
::
ArrayToString
(
feature_importances
,
max_feature_idx_
+
1
,
' '
);
std
::
string
ret
=
Common
::
ArrayToString
(
feature_importances
,
max_feature_idx_
+
1
,
' '
);
...
...
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