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
0e25841d
Unverified
Commit
0e25841d
authored
Dec 10, 2021
by
James Lamb
Committed by
GitHub
Dec 10, 2021
Browse files
[R-package] remove unused callback cb.reset.parameter (#4871)
parent
f71328d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
87 deletions
+0
-87
R-package/R/callback.R
R-package/R/callback.R
+0
-87
No files found.
R-package/R/callback.R
View file @
0e25841d
...
@@ -23,93 +23,6 @@ CB_ENV <- R6::R6Class(
...
@@ -23,93 +23,6 @@ CB_ENV <- R6::R6Class(
)
)
)
)
cb.reset.parameters
<-
function
(
new_params
)
{
if
(
!
identical
(
class
(
new_params
),
"list"
))
{
stop
(
sQuote
(
"new_params"
),
" must be a list"
)
}
# Deparse parameter list
pnames
<-
gsub
(
"\\."
,
"_"
,
names
(
new_params
))
nrounds
<-
NULL
# Run some checks in the beginning
init
<-
function
(
env
)
{
# Check for model environment
if
(
is.null
(
env
$
model
))
{
stop
(
"Env should have a "
,
sQuote
(
"model"
))
}
# Store boosting rounds
nrounds
<<-
env
$
end_iteration
-
env
$
begin_iteration
+
1L
# Check parameter names
for
(
n
in
pnames
)
{
# Set name
p
<-
new_params
[[
n
]]
# Check if function for parameter
if
(
is.function
(
p
))
{
# Check if requires at least two arguments
if
(
length
(
formals
(
p
))
!=
2L
)
{
stop
(
"Parameter "
,
sQuote
(
n
),
" is a function but not of two arguments"
)
}
# Check if numeric or character
}
else
if
(
is.numeric
(
p
)
||
is.character
(
p
))
{
# Check if length is matching
if
(
length
(
p
)
!=
nrounds
)
{
stop
(
"Length of "
,
sQuote
(
n
),
" has to be equal to length of "
,
sQuote
(
"nrounds"
))
}
}
else
{
stop
(
"Parameter "
,
sQuote
(
n
),
" is not a function or a vector"
)
}
}
return
(
invisible
(
NULL
))
}
callback
<-
function
(
env
)
{
# Check if rounds is null
if
(
is.null
(
nrounds
))
{
init
(
env
=
env
)
}
# Store iteration
i
<-
env
$
iteration
-
env
$
begin_iteration
# Apply list on parameters
pars
<-
lapply
(
new_params
,
function
(
p
)
{
if
(
is.function
(
p
))
{
return
(
p
(
i
,
nrounds
))
}
p
[
i
]
})
if
(
!
is.null
(
env
$
model
))
{
return
(
env
$
model
$
reset_parameter
(
params
=
pars
))
}
return
(
invisible
(
NULL
))
}
attr
(
callback
,
"call"
)
<-
match.call
()
attr
(
callback
,
"is_pre_iteration"
)
<-
TRUE
attr
(
callback
,
"name"
)
<-
"cb.reset.parameters"
return
(
callback
)
}
# Format the evaluation metric string
# Format the evaluation metric string
format.eval.string
<-
function
(
eval_res
,
eval_err
)
{
format.eval.string
<-
function
(
eval_res
,
eval_err
)
{
...
...
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