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
5442aa97
Unverified
Commit
5442aa97
authored
Sep 05, 2018
by
James Lamb
Committed by
GitHub
Sep 05, 2018
Browse files
[R-package] fixed examples in lgb.plot.importance (#1635)
parent
59702674
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
31 deletions
+50
-31
R-package/R/lgb.plot.importance.R
R-package/R/lgb.plot.importance.R
+31
-31
R-package/man/lgb.plot.importance.Rd
R-package/man/lgb.plot.importance.Rd
+19
-0
No files found.
R-package/R/lgb.plot.importance.R
View file @
5442aa97
...
@@ -17,23 +17,23 @@
...
@@ -17,23 +17,23 @@
#' and silently returns a processed data.table with \code{top_n} features sorted by defined importance.
#' and silently returns a processed data.table with \code{top_n} features sorted by defined importance.
#'
#'
#' @examples
#' @examples
# data(agaricus.train, package = "lightgbm")
#
'
data(agaricus.train, package = "lightgbm")
# train <- agaricus.train
#
'
train <- agaricus.train
# dtrain <- lgb.Dataset(train$data, label = train$label)
#
'
dtrain <- lgb.Dataset(train$data, label = train$label)
#
#
'
# params <- list(
#
'
params <- list(
# objective = "binary"
#
'
objective = "binary"
# , learning_rate = 0.01
#
'
, learning_rate = 0.01
# , num_leaves = 63
#
'
, num_leaves = 63
# , max_depth = -1
#
'
, max_depth = -1
# , min_data_in_leaf = 1
#
'
, min_data_in_leaf = 1
# , min_sum_hessian_in_leaf = 1
#
'
, min_sum_hessian_in_leaf = 1
# )
#
'
)
#
#
'
# model <- lgb.train(params, dtrain, 20)
#
'
model <- lgb.train(params, dtrain, 20)
#
#
'
# tree_imp <- lgb.importance(model, percentage = TRUE)
#
'
tree_imp <- lgb.importance(model, percentage = TRUE)
# lgb.plot.importance(tree_imp, top_n = 10, measure = "Gain")
#
'
lgb.plot.importance(tree_imp, top_n = 10, measure = "Gain")
#' @importFrom graphics barplot par
#' @importFrom graphics barplot par
#' @export
#' @export
lgb.plot.importance
<-
function
(
tree_imp
,
lgb.plot.importance
<-
function
(
tree_imp
,
...
...
R-package/man/lgb.plot.importance.Rd
View file @
5442aa97
...
@@ -29,3 +29,22 @@ Plot previously calculated feature importance: Gain, Cover and Frequency, as a b
...
@@ -29,3 +29,22 @@ Plot previously calculated feature importance: Gain, Cover and Frequency, as a b
The
graph
represents
each
feature
as
a
horizontal
bar
of
length
proportional
to
the
defined
importance
of
a
feature
.
The
graph
represents
each
feature
as
a
horizontal
bar
of
length
proportional
to
the
defined
importance
of
a
feature
.
Features
are
shown
ranked
in
a
decreasing
importance
order
.
Features
are
shown
ranked
in
a
decreasing
importance
order
.
}
}
\
examples
{
data
(
agaricus
.
train
,
package
=
"lightgbm"
)
train
<-
agaricus
.
train
dtrain
<-
lgb
.
Dataset
(
train
$
data
,
label
=
train
$
label
)
params
<-
list
(
objective
=
"binary"
,
learning_rate
=
0.01
,
num_leaves
=
63
,
max_depth
=
-
1
,
min_data_in_leaf
=
1
,
min_sum_hessian_in_leaf
=
1
)
model
<-
lgb
.
train
(
params
,
dtrain
,
20
)
tree_imp
<-
lgb
.
importance
(
model
,
percentage
=
TRUE
)
lgb
.
plot
.
importance
(
tree_imp
,
top_n
=
10
,
measure
=
"Gain"
)
}
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