Removed magrittr dependency in callbacks.R (#6855)
This commit is contained in:
parent
4224c08cac
commit
2e8c101b4a
@ -560,7 +560,6 @@ cb.cv.predict <- function(save_models = FALSE) {
|
|||||||
#' #
|
#' #
|
||||||
#' # In the iris dataset, it is hard to linearly separate Versicolor class from the rest
|
#' # In the iris dataset, it is hard to linearly separate Versicolor class from the rest
|
||||||
#' # without considering the 2nd order interactions:
|
#' # without considering the 2nd order interactions:
|
||||||
#' require(magrittr)
|
|
||||||
#' x <- model.matrix(Species ~ .^2, iris)[,-1]
|
#' x <- model.matrix(Species ~ .^2, iris)[,-1]
|
||||||
#' colnames(x)
|
#' colnames(x)
|
||||||
#' dtrain <- xgb.DMatrix(scale(x), label = 1*(iris$Species == "versicolor"))
|
#' dtrain <- xgb.DMatrix(scale(x), label = 1*(iris$Species == "versicolor"))
|
||||||
@ -581,7 +580,7 @@ cb.cv.predict <- function(save_models = FALSE) {
|
|||||||
#' bst <- xgb.train(param, dtrain, list(tr=dtrain), nrounds = 200, eta = 0.8,
|
#' bst <- xgb.train(param, dtrain, list(tr=dtrain), nrounds = 200, eta = 0.8,
|
||||||
#' updater = 'coord_descent', feature_selector = 'thrifty', top_k = 1,
|
#' updater = 'coord_descent', feature_selector = 'thrifty', top_k = 1,
|
||||||
#' callbacks = list(cb.gblinear.history()))
|
#' callbacks = list(cb.gblinear.history()))
|
||||||
#' xgb.gblinear.history(bst) %>% matplot(type = 'l')
|
#' matplot(xgb.gblinear.history(bst), type = 'l')
|
||||||
#' # Componentwise boosting is known to have similar effect to Lasso regularization.
|
#' # Componentwise boosting is known to have similar effect to Lasso regularization.
|
||||||
#' # Try experimenting with various values of top_k, eta, nrounds,
|
#' # Try experimenting with various values of top_k, eta, nrounds,
|
||||||
#' # as well as different feature_selectors.
|
#' # as well as different feature_selectors.
|
||||||
@ -590,7 +589,7 @@ cb.cv.predict <- function(save_models = FALSE) {
|
|||||||
#' bst <- xgb.cv(param, dtrain, nfold = 5, nrounds = 100, eta = 0.8,
|
#' bst <- xgb.cv(param, dtrain, nfold = 5, nrounds = 100, eta = 0.8,
|
||||||
#' callbacks = list(cb.gblinear.history()))
|
#' callbacks = list(cb.gblinear.history()))
|
||||||
#' # coefficients in the CV fold #3
|
#' # coefficients in the CV fold #3
|
||||||
#' xgb.gblinear.history(bst)[[3]] %>% matplot(type = 'l')
|
#' matplot(xgb.gblinear.history(bst)[[3]], type = 'l')
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #### Multiclass classification:
|
#' #### Multiclass classification:
|
||||||
@ -603,15 +602,15 @@ cb.cv.predict <- function(save_models = FALSE) {
|
|||||||
#' bst <- xgb.train(param, dtrain, list(tr=dtrain), nrounds = 70, eta = 0.5,
|
#' bst <- xgb.train(param, dtrain, list(tr=dtrain), nrounds = 70, eta = 0.5,
|
||||||
#' callbacks = list(cb.gblinear.history()))
|
#' callbacks = list(cb.gblinear.history()))
|
||||||
#' # Will plot the coefficient paths separately for each class:
|
#' # Will plot the coefficient paths separately for each class:
|
||||||
#' xgb.gblinear.history(bst, class_index = 0) %>% matplot(type = 'l')
|
#' matplot(xgb.gblinear.history(bst, class_index = 0), type = 'l')
|
||||||
#' xgb.gblinear.history(bst, class_index = 1) %>% matplot(type = 'l')
|
#' matplot(xgb.gblinear.history(bst, class_index = 1), type = 'l')
|
||||||
#' xgb.gblinear.history(bst, class_index = 2) %>% matplot(type = 'l')
|
#' matplot(xgb.gblinear.history(bst, class_index = 2), type = 'l')
|
||||||
#'
|
#'
|
||||||
#' # CV:
|
#' # CV:
|
||||||
#' bst <- xgb.cv(param, dtrain, nfold = 5, nrounds = 70, eta = 0.5,
|
#' bst <- xgb.cv(param, dtrain, nfold = 5, nrounds = 70, eta = 0.5,
|
||||||
#' callbacks = list(cb.gblinear.history(FALSE)))
|
#' callbacks = list(cb.gblinear.history(FALSE)))
|
||||||
#' # 1st forld of 1st class
|
#' # 1st fold of 1st class
|
||||||
#' xgb.gblinear.history(bst, class_index = 0)[[1]] %>% matplot(type = 'l')
|
#' matplot(xgb.gblinear.history(bst, class_index = 0)[[1]], type = 'l')
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
cb.gblinear.history <- function(sparse=FALSE) {
|
cb.gblinear.history <- function(sparse=FALSE) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user