fix example
This commit is contained in:
parent
2ca4016a1f
commit
8252d0d9f5
@ -52,11 +52,11 @@
|
|||||||
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2,
|
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2,
|
||||||
#' eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
#' eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
||||||
#'
|
#'
|
||||||
#' # train$data@@Dimnames[[2]] represents the column names of the sparse matrix.
|
#' # agaricus.train$data@@Dimnames[[2]] represents the column names of the sparse matrix.
|
||||||
#' xgb.importance(train$data@@Dimnames[[2]], model = bst)
|
#' xgb.importance(agaricus.train$data@@Dimnames[[2]], model = bst)
|
||||||
#'
|
#'
|
||||||
#' # Same thing with co-occurence computation this time
|
#' # Same thing with co-occurence computation this time
|
||||||
#' xgb.importance(train$data@@Dimnames[[2]], model = bst, data = train$data, label = train$label)
|
#' xgb.importance(agaricus.train$data@@Dimnames[[2]], model = bst, data = agaricus.train$data, label = agaricus.train$label)
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
xgb.importance <- function(feature_names = NULL, model = NULL, data = NULL, label = NULL, target = function(x) ( (x + label) == 2)){
|
xgb.importance <- function(feature_names = NULL, model = NULL, data = NULL, label = NULL, target = function(x) ( (x + label) == 2)){
|
||||||
|
|||||||
@ -19,13 +19,12 @@
|
|||||||
#' #Both dataset are list with two items, a sparse matrix and labels
|
#' #Both dataset are list with two items, a sparse matrix and labels
|
||||||
#' #(labels = outcome column which will be learned).
|
#' #(labels = outcome column which will be learned).
|
||||||
#' #Each column of the sparse Matrix is a feature in one hot encoding format.
|
#' #Each column of the sparse Matrix is a feature in one hot encoding format.
|
||||||
#' train <- agaricus.train
|
|
||||||
#'
|
#'
|
||||||
#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
|
#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2,
|
||||||
#' eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
#' eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
||||||
#'
|
#'
|
||||||
#' #train$data@@Dimnames[[2]] represents the column names of the sparse matrix.
|
#' #agaricus.train$data@@Dimnames[[2]] represents the column names of the sparse matrix.
|
||||||
#' importance_matrix <- xgb.importance(train$data@@Dimnames[[2]], model = bst)
|
#' importance_matrix <- xgb.importance(agaricus.train$data@@Dimnames[[2]], model = bst)
|
||||||
#' xgb.plot.importance(importance_matrix)
|
#' xgb.plot.importance(importance_matrix)
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
|
|||||||
@ -58,11 +58,11 @@ data(agaricus.train, package='xgboost')
|
|||||||
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2,
|
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2,
|
||||||
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
||||||
|
|
||||||
# train$data@Dimnames[[2]] represents the column names of the sparse matrix.
|
# agaricus.train$data@Dimnames[[2]] represents the column names of the sparse matrix.
|
||||||
xgb.importance(train$data@Dimnames[[2]], model = bst)
|
xgb.importance(agaricus.train$data@Dimnames[[2]], model = bst)
|
||||||
|
|
||||||
# Same thing with co-occurence computation this time
|
# Same thing with co-occurence computation this time
|
||||||
xgb.importance(train$data@Dimnames[[2]], model = bst, data = train$data, label = train$label)
|
xgb.importance(agaricus.train$data@Dimnames[[2]], model = bst, data = agaricus.train$data, label = agaricus.train$label)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,13 +28,12 @@ data(agaricus.train, package='xgboost')
|
|||||||
#Both dataset are list with two items, a sparse matrix and labels
|
#Both dataset are list with two items, a sparse matrix and labels
|
||||||
#(labels = outcome column which will be learned).
|
#(labels = outcome column which will be learned).
|
||||||
#Each column of the sparse Matrix is a feature in one hot encoding format.
|
#Each column of the sparse Matrix is a feature in one hot encoding format.
|
||||||
train <- agaricus.train
|
|
||||||
|
|
||||||
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
|
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2,
|
||||||
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
||||||
|
|
||||||
#train$data@Dimnames[[2]] represents the column names of the sparse matrix.
|
#agaricus.train$data@Dimnames[[2]] represents the column names of the sparse matrix.
|
||||||
importance_matrix <- xgb.importance(train$data@Dimnames[[2]], model = bst)
|
importance_matrix <- xgb.importance(agaricus.train$data@Dimnames[[2]], model = bst)
|
||||||
xgb.plot.importance(importance_matrix)
|
xgb.plot.importance(importance_matrix)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user