mlr3
mlr3 copied to clipboard
Warning if an object from an old mlr3-version is loaded
Loading e.g. a Task
that was generated with an old mlr3-version using readRDS()
will give errors like this: https://github.com/mb706/autoxgboost3/issues/2#issuecomment-596969950 . Maybe there is a way to make these kinds of errors more obvious to the user.
Is this related to the change of the serialization version in saveRDS()
in >= R 3.6.0?
no, this is just from changing the API of R6-objects. In S3 this is less of an issue; if the data layout does not change then "old" objects can be used with new versions of a software. With R6 the objects themselves carry their functions with them and are more likely to be incompatible with updates.
I wonder if it would be best to have a special serialize/deserialize method for the objects. This way we would only save the data and would be able to fix API changes during deserialization/reconstruction.
it would be nicer to work with R's own serialization because that also works when the task is "hidden" somewhere in a list or environment of a function (e.g. objective function of an optimization algorithm). I can see though that this is technically difficult to implement.
Hi - not sure if this belongs here, but I found an example which may be a clash from another package.
> library("mlr3")
>
> #load an example
> task = tsk("pima")
> print(task)
<TaskClassif:pima> (768 x 9)
* Target: diabetes
* Properties: twoclass
* Features (8):
- dbl (8): age, glucose, insulin, mass, pedigree, pregnant, pressure, triceps
>
> learner = lrn("classif.rpart")
> learner$param_set
ParamSet:
id class lower upper levels default value
1: minsplit ParamInt 1 Inf 20
2: minbucket ParamInt 1 Inf <NoDefault>
3: cp ParamDbl 0 1 0.01
4: maxcompete ParamInt 0 Inf 4
5: maxsurrogate ParamInt 0 Inf 5
6: maxdepth ParamInt 1 30 30
7: usesurrogate ParamInt 0 2 2
8: surrogatestyle ParamInt 0 1 0
9: xval ParamInt 0 Inf 10 0
>
> #load example param set
> library("paradox")
> tune_ps = ParamSet$new(list(
+ ParamDbl$new("cp", lower = 0.001, upper = 0.1),
+ ParamInt$new("minsplit", lower = 1, upper = 10)
+ ))
>
> #we can see the contents:
> tune_ps
ParamSet:
id class lower upper levels default value
1: cp ParamDbl 0.001 0.1 <NoDefault>
2: minsplit ParamInt 1.000 10.0 <NoDefault>
>
> #but when we load another package
> library(ParamHelpers)
> tune_ps #we cannot see the contents:
[1] "Empty parameter set."
FYI this is known internally, but idk if / where we have the issue about this. It's just broken, don't load old and new mlr (or paradox & ParamHelpers) in the same R sessionl. Sorry about this :-(
we agrreed that we woukd store the version nr of the parent package, by doing this in leanify.
in general, this a complicated topic. we could later either
- separate logic / class code better from the data
- maybe ship converter function for old mlr object versions