Skip to content

Commit 1064f2a

Browse files
authored
Merge pull request #51 from ymattu/fix/xgb
Fix/xgb
2 parents 0b97cfe + ffdfda6 commit 1064f2a

13 files changed

Lines changed: 74 additions & 36 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ data-raw/
1010
^README-.*\.png$
1111
^logo\.png$
1212
^docs$
13+
^cran-comments\.md$

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: MlBayesOpt
22
Type: Package
33
Title: Hyperparameter Tuning for Machine Learning, Using Bayesian Optimization
4-
Version: 0.3.2
4+
Version: 0.3.3
55
Authors@R: person("Yuya", "Matsumura", role = c("aut", "cre"), email = "mattu.yuya@gmail.com")
66
Maintainer: Yuya Matsumura <mattu.yuya@gmail.com>
77
Description: This package provides the hyperparameter tuning using bayesian

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# MlBayesOpt 0.3.3
2+
- Fix Buggs for `xgb_cv_opt()`
3+
14
# MlBayesOpt 0.3.2
25
- Add a vignette
36
- Changed a option `num_tree_range` in `rf_opt()` to `num_tree`

R/xgb_cv_opt.R

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
##' \item \code{multi:softprob} same as softmax, but prediction outputs a vector of ndata * nclass elements, which can be further reshaped to ndata, nclass matrix. The result contains predicted probabilities of each data point belonging to each class.
1414
##' \item \code{rank:pairwise} set xgboost to do ranking task by minimizing the pairwise loss.
1515
##' }
16-
##' @param evalmetric evaluation metrics for validation data. Users can pass a self-defined function to it.
17-
##' Default: metric will be assigned according to objective(rmse for regression, and error for classification, mean average precision for ranking).
18-
##' List is provided in detail section.
16+
##' @param evalmetric evaluation metrics for validation data. Users can pass a self-defined function to it. Default: metric will be assigned according to objective(rmse for regression, and error for classification, mean average precision for ranking).
17+
##' \itemize{
18+
##' \item \code{error} binary classification error rate
19+
##' \item \code{rmse} Rooted mean square error
20+
##' \item \code{logloss} negative log-likelihood function
21+
##' \item \code{auc} Area under curve
22+
##' \item \code{merror} Exact matching error, used to evaluate multi-class classification
23+
##' }
1924
##' @param n_folds K for cross Validation
2025
##' @param eta_range The range of eta(default is c(0.1, 1L))
2126
##' @param max_depth_range The range of max_depth(default is c(4L, 6L))
@@ -114,7 +119,7 @@ xgb_cv_opt <- function(data,
114119
}
115120

116121
#about classes
117-
if (objectfun == "binary:logistic"){
122+
if (grepl("logi", objectfun) == TRUE){
118123
xgb_cv <- function(object_fun,
119124
eval_met,
120125
num_classes,
@@ -142,7 +147,7 @@ xgb_cv_opt <- function(data,
142147
early_stopping_rounds = 5, maximize = TRUE, verbose = 0,
143148
nrounds = nrounds_opt)
144149

145-
if (eval_met %in% c("auc", "logloss", "mlogloss")) {
150+
if (eval_met %in% c("auc", "ndcg", "map")) {
146151
s <- max(cv$evaluation_log[, 4])
147152
} else {
148153
s <- max(-(cv$evaluation_log[, 4]))
@@ -181,7 +186,7 @@ xgb_cv_opt <- function(data,
181186
early_stopping_rounds = 5, maximize = TRUE, verbose = 0,
182187
nrounds = nrounds_opt)
183188

184-
if (eval_met %in% c("auc", "logloss", "mlogloss")) {
189+
if (eval_met %in% c("auc", "ndcg", "map")) {
185190
s <- max(cv$evaluation_log[, 4])
186191
} else {
187192
s <- max(-(cv$evaluation_log[, 4]))

R/xgb_opt.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
##' \item \code{multi:softprob} same as softmax, but prediction outputs a vector of ndata * nclass elements, which can be further reshaped to ndata, nclass matrix. The result contains predicted probabilities of each data point belonging to each class.
1616
##' \item \code{rank:pairwise} set xgboost to do ranking task by minimizing the pairwise loss.
1717
##' }
18-
##' @param evalmetric evaluation metrics for validation data. Users can pass a self-defined function to it. Default: metric will be assigned according to objective(rmse for regression, and error for classification, mean average precision for ranking). List is provided in detail section.
18+
##' @param evalmetric evaluation metrics for validation data. Users can pass a self-defined function to it. Default: metric will be assigned according to objective(rmse for regression, and error for classification, mean average precision for ranking).
19+
##' \itemize{
20+
##' \item \code{error} binary classification error rate
21+
##' \item \code{rmse} Rooted mean square error
22+
##' \item \code{logloss} negative log-likelihood function
23+
##' \item \code{auc} Area under curve
24+
##' \item \code{merror} Exact matching error, used to evaluate multi-class classification
25+
##' }
1926
##' @param eta_range The range of eta
2027
##' @param max_depth_range The range of max_depth
2128
##' @param nrounds_range The range of nrounds
@@ -110,7 +117,7 @@ xgb_opt <- function(train_data,
110117

111118

112119
#about classes
113-
if (objectfun == "binary:logistic"){
120+
if (grepl("logi", objectfun) == TRUE){
114121
xgb_holdout <- function(object_fun,
115122
eval_met,
116123
num_classes,

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ res0 <- svm_cv_opt(data = iris,
6060
n_folds = 3,
6161
init_points = 10,
6262
n_iter = 1)
63-
#> elapsed = 0.07 Round = 1 gamma_opt = 3.3299 cost_opt = 11.7670 Value = 0.9333
64-
#> elapsed = 0.34 Round = 2 gamma_opt = 5.5515 cost_opt = 76.1740 Value = 0.9067
65-
#> elapsed = 0.02 Round = 3 gamma_opt = 3.2744 cost_opt = 14.1882 Value = 0.9400
63+
#> elapsed = 0.04 Round = 1 gamma_opt = 3.3299 cost_opt = 11.7670 Value = 0.9333
64+
#> elapsed = 0.16 Round = 2 gamma_opt = 5.5515 cost_opt = 76.1740 Value = 0.9067
65+
#> elapsed = 0.01 Round = 3 gamma_opt = 3.2744 cost_opt = 14.1882 Value = 0.9400
6666
#> elapsed = 0.01 Round = 4 gamma_opt = 2.1175 cost_opt = 76.6932 Value = 0.9200
6767
#> elapsed = 0.01 Round = 5 gamma_opt = 3.1619 cost_opt = 84.2154 Value = 0.9600
68-
#> elapsed = 0.02 Round = 6 gamma_opt = 9.4727 cost_opt = 77.6772 Value = 0.8933
69-
#> elapsed = 0.05 Round = 7 gamma_opt = 6.6175 cost_opt = 13.3914 Value = 0.9267
68+
#> elapsed = 0.01 Round = 6 gamma_opt = 9.4727 cost_opt = 77.6772 Value = 0.8933
69+
#> elapsed = 0.01 Round = 7 gamma_opt = 6.6175 cost_opt = 13.3914 Value = 0.9267
7070
#> elapsed = 0.01 Round = 8 gamma_opt = 8.8943 cost_opt = 80.5955 Value = 0.8733
71-
#> elapsed = 0.02 Round = 9 gamma_opt = 3.3808 cost_opt = 89.6793 Value = 0.9333
72-
#> elapsed = 0.03 Round = 10 gamma_opt = 4.3481 cost_opt = 92.6987 Value = 0.9000
73-
#> elapsed = 0.02 Round = 11 gamma_opt = 2.9508 cost_opt = 84.8600 Value = 0.9467
71+
#> elapsed = 0.01 Round = 9 gamma_opt = 3.3808 cost_opt = 89.6793 Value = 0.9333
72+
#> elapsed = 0.01 Round = 10 gamma_opt = 4.3481 cost_opt = 92.6987 Value = 0.9000
73+
#> elapsed = 0.01 Round = 11 gamma_opt = 2.9508 cost_opt = 84.8600 Value = 0.9467
7474
#>
7575
#> Best Parameters Found:
7676
#> Round = 5 gamma_opt = 3.1619 cost_opt = 84.2154 Value = 0.9600

docs/articles/MlBayesOpt.html

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/xgb_cv_opt.html

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/xgb_opt.html

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)