-
-
Notifications
You must be signed in to change notification settings - Fork 48
-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in lightgbm predict 'reshape' argument is no longer supported. #217
Comments
Hey, thanks for raising this issue. Unfortunately the code you provide does not run for me. |
Thanks for replying back. Here it is. No GPU now.
|
there is no package tidyext (I presume it is tixytext?) and also here is no function onehot. Please read the instructions in the bug report template I just linked |
my bad, I only tried to install from CRAN... |
I cannot reproduce it. Did you try updating lightgbm? |
I have a feeling it is because lightgbm may have upgraded. I cannot use the CRAN version of lightgbm because that does not support the full GPU configuration that I have. So I had to build the lightgbm from github as well (https://lightgbm.readthedocs.io/en/latest/R/index.html). So I got lightgbm working in the GPU cluster but when I integrate it with the mlr3 framework, it crashes.
|
Sorry I had never used reprex before. I had to learn out how to get it working. Here is it now finally. library(mlr3verse)
#> Loading required package: mlr3
library(mlr3extralearners)
library(lightgbm)
library(DALEXtra)
#> Loading required package: DALEX
#> Welcome to DALEX (version: 2.4.2).
#> Find examples and detailed introduction at: http://ema.drwhy.ai/
#> Anaconda not found on your computer. Conda related functionality such as create_env.R and condaenv and yml parameters from explain_scikitlearn will not be available
library(tidyext)
titanic_imputed$survived <- as.factor(titanic_imputed$survived)
num_classes <- length(unique(titanic_imputed$survived))
df <- onehot(titanic_imputed,
var = c("gender", "class", "embarked"),
keep.original = FALSE
)
task_classif <- as_task_classif(
x = df,
target = "survived"
)
learner_classif <- lrn(
seed = 101L,
"classif.lightgbm",
objective = "binary",
metric = "binary_logloss",
device_type = "cpu",
predict_type = "prob",
learning_rate = to_tune(1e-04, 1e-1, logscale = TRUE),
num_iterations = to_tune(p_int(50, 100)),
max_bin = 63L,
num_leaves = 255L,
tree_learner = "serial",
min_data_in_leaf = 1L,
min_sum_hessian_in_leaf = 100,
num_threads = 32L
)
print(task_classif)
#> <TaskClassif:df> (2207 x 18)
#> * Target: survived
#> * Properties: twoclass
#> * Features (17):
#> - dbl (17): age, class_1st, class_2nd, class_3rd, class_deck.crew,
#> class_engineering.crew, class_restaurant.staff,
#> class_victualling.crew, embarked_Belfast, embarked_Cherbourg,
#> embarked_Queenstown, embarked_Southampton, fare, gender_female,
#> gender_male, parch, sibsp
print(learner_classif)
#> <LearnerClassifLightGBM:classif.lightgbm>: Gradient Boosting
#> * Model: -
#> * Parameters: num_threads=32, verbose=-1, convert_categorical=TRUE,
#> seed=101, objective=binary, metric=binary_logloss, device_type=cpu,
#> learning_rate=<RangeTuneToken>, num_iterations=<ObjectTuneToken>,
#> max_bin=63, num_leaves=255, tree_learner=serial, min_data_in_leaf=1,
#> min_sum_hessian_in_leaf=100
#> * Packages: mlr3, mlr3extralearners, lightgbm
#> * Predict Type: prob
#> * Feature types: numeric, integer, factor, logical
#> * Properties: importance, missings, multiclass, twoclass, weights
df_tuned <- tune(
method = "irace",
term_evals = 100,
task = task_classif,
learner = learner_classif,
resampling = rsmp("repeated_cv", repeats = 5, folds = 10),
measure = msr("classif.fbeta")
)
#> INFO [12:41:40.170] [bbotk] Starting to optimize 2 parameter(s) with '<OptimizerIrace>' and '<TerminatorEvals> [n_evals=100, k=0]'
#> # 2022-07-16 12:41:40 UTC: Initialization
#> # Elitist race
#> # Elitist new instances: 1
#> # Elitist limit: 2
#> # nbIterations: 3
#> # minNbSurvival: 3
#> # nbParameters: 2
#> # seed: 808902185
#> # confidence level: 0.95
#> # budget: 100
#> # mu: 5
#> # deterministic: FALSE
#>
#> # 2022-07-16 12:41:40 UTC: Iteration 1 of 3
#> # experimentsUsedSoFar: 0
#> # remainingBudget: 100
#> # currentBudget: 33
#> # nbConfigurations: 5
#> # Markers:
#> x No test is performed.
#> c Configurations are discarded only due to capping.
#> - The test is performed and some configurations are discarded.
#> = The test is performed but no configuration is discarded.
#> ! The test is performed and configurations could be discarded but elite configurations are preserved.
#> . All alive configurations are elite and nothing is discarded
#>
#> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+
#> | | Instance| Alive| Best| Mean best| Exp so far| W time| rho|KenW| Qvar|
#> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+
#> INFO [12:41:40.314] [bbotk] Evaluating 5 configuration(s)
#> INFO [12:41:40.593] [mlr3] Running benchmark with 250 resampling iterations
#> INFO [12:41:40.628] [mlr3] Applying learner 'classif.lightgbm' on task 'df' (iter 29/50)
#> Error in predict.lgb.Booster(object = self$model, data = newdata, reshape = TRUE, : 'reshape' argument is no longer supported. Created on 2022-07-16 by the reprex package (v2.0.1) Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.3 (2020-02-29)
#> os Ubuntu 20.04.4 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Etc/UTC
#> date 2022-07-16
#> pandoc 2.18 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> backports 1.4.1 2021-12-13 [1] CRAN (R 3.6.3)
#> bbotk 0.5.3 2022-05-04 [1] CRAN (R 3.6.3)
#> checkmate 2.1.0 2022-04-21 [1] CRAN (R 3.6.3)
#> cli 3.3.0 2022-04-25 [1] CRAN (R 3.6.3)
#> clue 0.3-61 2022-05-30 [1] CRAN (R 3.6.3)
#> cluster 2.1.0 2019-06-19 [4] CRAN (R 3.6.1)
#> clusterCrit 1.2.8 2018-07-26 [1] CRAN (R 3.6.3)
#> codetools 0.2-16 2018-12-24 [4] CRAN (R 3.5.2)
#> colorspace 2.0-3 2022-02-21 [1] CRAN (R 3.6.3)
#> crayon 1.5.1 2022-03-26 [1] CRAN (R 3.6.3)
#> DALEX * 2.4.2 2022-06-15 [1] CRAN (R 3.6.3)
#> DALEXtra * 2.2.1 2022-06-14 [1] CRAN (R 3.6.3)
#> data.table 1.14.2 2021-09-27 [1] CRAN (R 3.6.3)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 3.6.3)
#> dplyr 1.0.9 2022-04-28 [1] CRAN (R 3.6.3)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 3.6.3)
#> evaluate 0.15 2022-02-18 [1] CRAN (R 3.6.3)
#> fansi 1.0.3 2022-03-24 [1] CRAN (R 3.6.3)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 3.6.3)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 3.6.3)
#> future 1.26.1 2022-05-27 [1] CRAN (R 3.6.3)
#> future.apply 1.9.0 2022-04-25 [1] CRAN (R 3.6.3)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 3.6.3)
#> ggplot2 3.3.6 2022-05-03 [1] CRAN (R 3.6.3)
#> globals 0.15.1 2022-06-24 [1] CRAN (R 3.6.3)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 3.6.3)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.3)
#> highr 0.9 2021-04-16 [1] CRAN (R 3.6.3)
#> htmltools 0.5.2 2021-08-25 [1] CRAN (R 3.6.3)
#> irace 3.4.1 2020-03-31 [1] CRAN (R 3.6.3)
#> jsonlite 1.8.0 2022-02-22 [1] CRAN (R 3.6.3)
#> knitr 1.39 2022-04-26 [1] CRAN (R 3.6.3)
#> lattice 0.20-40 2020-02-19 [4] CRAN (R 3.6.2)
#> lgr 0.4.3 2021-09-16 [1] CRAN (R 3.6.3)
#> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 3.6.3)
#> lightgbm * 3.3.2.99 2022-07-15 [1] local
#> listenv 0.8.0 2019-12-05 [1] CRAN (R 3.6.3)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 3.6.3)
#> Matrix 1.2-18 2019-11-27 [4] CRAN (R 3.6.1)
#> mlr3 * 0.13.3 2022-03-01 [1] CRAN (R 3.6.3)
#> mlr3cluster 0.1.3 2022-04-06 [1] CRAN (R 3.6.3)
#> mlr3data 0.6.0 2022-03-18 [1] CRAN (R 3.6.3)
#> mlr3extralearners * 0.5.43 2022-07-16 [1] Github (mlr-org/mlr3extralearners@a77fe28)
#> mlr3filters 0.5.0 2022-01-25 [1] CRAN (R 3.6.3)
#> mlr3fselect 0.7.1 2022-05-03 [1] CRAN (R 3.6.3)
#> mlr3learners 0.5.3 2022-05-25 [1] CRAN (R 3.6.3)
#> mlr3measures 0.4.1 2022-01-13 [1] CRAN (R 3.6.3)
#> mlr3misc 0.10.0 2022-01-11 [1] CRAN (R 3.6.3)
#> mlr3pipelines 0.4.1 2022-05-15 [1] CRAN (R 3.6.3)
#> mlr3tuning 0.13.1 2022-05-03 [1] CRAN (R 3.6.3)
#> mlr3tuningspaces 0.3.0 2022-06-28 [1] CRAN (R 3.6.3)
#> mlr3verse * 0.2.5 2022-05-18 [1] CRAN (R 3.6.3)
#> mlr3viz 0.5.9 2022-05-25 [1] CRAN (R 3.6.3)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.3)
#> palmerpenguins 0.1.0 2020-07-23 [1] CRAN (R 3.6.3)
#> paradox 0.9.0 2022-04-18 [1] CRAN (R 3.6.3)
#> parallelly 1.32.0 2022-06-07 [1] CRAN (R 3.6.3)
#> pillar 1.7.0 2022-02-01 [1] CRAN (R 3.6.3)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.3)
#> png 0.1-7 2013-12-03 [1] CRAN (R 3.6.3)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 3.6.3)
#> R.cache 0.15.0 2021-04-30 [1] CRAN (R 3.6.3)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 3.6.3)
#> R.oo 1.25.0 2022-06-12 [1] CRAN (R 3.6.3)
#> R.utils 2.12.0 2022-06-28 [1] CRAN (R 3.6.3)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 3.6.3)
#> rappdirs 0.3.3 2021-01-31 [1] CRAN (R 3.6.3)
#> Rcpp 1.0.9 2022-07-08 [1] CRAN (R 3.6.3)
#> reprex 2.0.1 2021-08-05 [1] CRAN (R 3.6.3)
#> reticulate 1.25 2022-05-11 [1] CRAN (R 3.6.3)
#> rlang 1.0.4 2022-07-12 [1] CRAN (R 3.6.3)
#> rmarkdown 2.14 2022-04-25 [1] CRAN (R 3.6.3)
#> rstudioapi 0.13 2020-11-12 [1] CRAN (R 3.6.3)
#> scales 1.2.0 2022-04-13 [1] CRAN (R 3.6.3)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 3.6.3)
#> stringi 1.7.8 2022-07-11 [1] CRAN (R 3.6.3)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.3)
#> styler 1.7.0 2022-03-13 [1] CRAN (R 3.6.3)
#> tibble 3.1.7 2022-05-03 [1] CRAN (R 3.6.3)
#> tidyext * 0.3.6 2022-07-16 [1] Github (m-clark/tidyext@87df6da)
#> tidyr 1.2.0 2022-02-01 [1] CRAN (R 3.6.3)
#> tidyselect 1.1.2 2022-02-21 [1] CRAN (R 3.6.3)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 3.6.3)
#> uuid 1.1-0 2022-04-19 [1] CRAN (R 3.6.3)
#> vctrs 0.4.1 2022-04-13 [1] CRAN (R 3.6.3)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 3.6.3)
#> xfun 0.31 2022-05-10 [1] CRAN (R 3.6.3)
#> yaml 2.3.5 2022-02-21 [1] CRAN (R 3.6.3)
#>
#> [1] /home/sheetal/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library
#>
#> ────────────────────────────────────────────────────────────────────────────── |
Yes, also with the development version of lightgbm I can reproduce it now, I will hopefully make a PR later (this problem is an easy fix but I think the lightgbm learner requires some more updates with respect to its parameters.) |
Good to hear. Please just message me whenever you want me to test it out. Thanks. |
So here is the PR I started: #218 |
That reshape message seems gone. However I think I may have a usage error, Sorry to ask a usage question. Now I am getting an error as follows in the tune line above. What am I missing here?
|
I think I corrected that. There still seems to be a problem with the way weights have to be set in the dev version that I have to address later. Lmk if it solves your issue |
Thanks. At the moment I seem to have crossed this issue. I can build models and predict and do basic things. Please let me know whenever this is merged to mainline so that I get out of this tree. |
yep.......weights are not working yet. Waiting for your advice on how to use weights |
lightgbm renamed their parameters, I think the branch should now work, can you check? |
Sorry to bother with usage. But is this the right way to add weights? If weights is a new computed column in df.train. I am trying to avoid
|
Unfortunately this will not work currently, I will raise an issue in mlr3 and suggest this change. library(mlr3)
task = as_task_classif(iris, target = "Species")
print(task)
#> <TaskClassif:iris> (150 x 5)
#> * Target: Species
#> * Properties: multiclass
#> * Features (4):
#> - dbl (4): Petal.Length, Petal.Width, Sepal.Length, Sepal.Width
iris$weight = runif(150)
task = as_task_classif(iris, target = "Species")
task$set_col_roles("Sepal.Width", "weight")
print(task)
#> <TaskClassif:iris> (150 x 5)
#> * Target: Species
#> * Properties: multiclass, weights
#> * Features (4):
#> - dbl (4): Petal.Length, Petal.Width, Sepal.Length, weight
#> * Weights: Sepal.Width Created on 2022-07-19 by the reprex package (v2.0.1) |
* fixed shape parameter (#217) and started correcting lgb params * fix classif test lightgbm * fix predict in classif lightgbm * lightgbm renamed newdata -> data in next version * correct lightgbm and implement hotstart * version bump * fix: lightgbm paramtest * fix: hotstarting for regr lightgbm * Update learner table * fix: make lightgbm regression predict work with lgb dev version * Update learner table Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
The lightgbm update is now merged. I did not test excessively against the dev version of lightgbm, so if you encounter more problems, please let me know. |
This error does not happen in other classif algo
The text was updated successfully, but these errors were encountered: