giuseppec / giuseppec/mlr3calibration

Error in .__Graph__predict(self = self, private = private, super = super, : Cannot predict, Graph has not been trained yet

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

> # Load a binary classification task
> set.seed(1)
> library(mlr3calibration)
> library(mlr3verse)
> data("Sonar", package = "mlbench")
> task = as_task_classif(Sonar, target = "Class", positive = "M")
> splits = partition(task)
> task_train = task$clone()$filter(splits$train)
> task_test = task$clone()$filter(splits$test)
>
> # Initialize the uncalibrated learner
> learner_uncal <- lrn("classif.xgboost", nrounds = 50, predict_type = "prob")
>
> # Initialize the calibrated learner
> rsmp <- rsmp("cv", folds = 5)
> learner_cal <- as_learner(PipeOpCalibration$new(learner = learner_uncal,
+ method = "beta",
+ rsmp = rsmp))
>
> # Set ID's for the learners
> learner_uncal$id <- "Uncalibrated Learner"
> learner_cal$id <- "Calibrated Learner"
>
> # Train the learners
> learner_uncal$train(task_train)
> learner_cal$train(task_train)
[1] -456.1043
[1] 15.28018
[1] -39.84187
[1] 9.989902
[1] -19.32693
[1] 26.69576
[1] -27.22082
[1] 2.789276
[1] -60.92008
[1] 64.59263
Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred
This happened in PipeOp classif.xgboost's $train()
>
> # Predict the Learners
> preds_uncal <- learner_uncal$predict(task_test)
> preds_cal <- learner_cal$predict(task_test)
Error in .__Graph__predict(self = self, private = private, super = super, :
Cannot predict, Graph has not been trained yet

Based on the implementation provided in the above code, I was unable to achieve complete and accurate predictions, as the model did not perform as expected during the calibration process

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the reproduction in the issue, focusing on PipeOpCalibration$new and the learner_train/predict calls. Trace why the calibrated learner's graph is not considered trained after learner_cal$train(task_train). Done means the reported calibrated prediction completes without the graph-not-trained error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.