Generate a Randomized Response Prediction
Source:R/PipeOpRandomResponse.R
mlr_pipeops_randomresponse.Rd
Takes in a Prediction
of predict_type
"prob"
(for PredictionClassif
) or "se"
(for PredictionRegr
) and generates a randomized "response"
prediction.
For "prob"
, the responses are sampled according to
the probabilities of the input PredictionClassif
. For "se"
,
responses are randomly drawn according to the rdistfun
parameter (default is rnorm
) by using
the original responses of the input PredictionRegr
as the mean and the
original standard errors of the input PredictionRegr
as the standard
deviation (sampling is done observation-wise).
Construction
id
::character(1)
Identifier of the resulting object, default"randomresponse"
.param_vals
:: namedlist
List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. Defaultlist()
.packages ::
character
Set of all required packages for theprivate$.predict()
methods related to therdistfun
parameter. Default ischaracter(0)
.
Input and Output Channels
PipeOpRandomResponse
has one input channel named "input"
, taking NULL
during training and
a Prediction
during prediction.
PipeOpRandomResponse
has one output channel named "output"
, producing NULL
during
training and a Prediction
with random responses during prediction.
State
The $state
is left empty (list()
).
Parameters
rdistfun
::function
A function for generating random responses when the predict type is"se"
. This function must accept the argumentsn
(integerish number of responses),mean
(numeric
for the mean), andsd
(numeric
for the standard deviation), and must vectorize overmean
andsd
. Default isrnorm
.
Internals
If the predict_type
of the input Prediction
does not match "prob"
or
"se"
, the input Prediction
will be returned unaltered.
Fields
Only fields inherited from PipeOp
.
Methods
Only methods inherited from PipeOp
.
See also
https://mlr-org.com/pipeops.html
Other PipeOps:
PipeOp
,
PipeOpEnsemble
,
PipeOpImpute
,
PipeOpTargetTrafo
,
PipeOpTaskPreproc
,
PipeOpTaskPreprocSimple
,
mlr_pipeops
,
mlr_pipeops_adas
,
mlr_pipeops_blsmote
,
mlr_pipeops_boxcox
,
mlr_pipeops_branch
,
mlr_pipeops_chunk
,
mlr_pipeops_classbalancing
,
mlr_pipeops_classifavg
,
mlr_pipeops_classweights
,
mlr_pipeops_colapply
,
mlr_pipeops_collapsefactors
,
mlr_pipeops_colroles
,
mlr_pipeops_copy
,
mlr_pipeops_datefeatures
,
mlr_pipeops_encode
,
mlr_pipeops_encodeimpact
,
mlr_pipeops_encodelmer
,
mlr_pipeops_featureunion
,
mlr_pipeops_filter
,
mlr_pipeops_fixfactors
,
mlr_pipeops_histbin
,
mlr_pipeops_ica
,
mlr_pipeops_imputeconstant
,
mlr_pipeops_imputehist
,
mlr_pipeops_imputelearner
,
mlr_pipeops_imputemean
,
mlr_pipeops_imputemedian
,
mlr_pipeops_imputemode
,
mlr_pipeops_imputeoor
,
mlr_pipeops_imputesample
,
mlr_pipeops_kernelpca
,
mlr_pipeops_learner
,
mlr_pipeops_learner_pi_cvplus
,
mlr_pipeops_learner_quantiles
,
mlr_pipeops_missind
,
mlr_pipeops_modelmatrix
,
mlr_pipeops_multiplicityexply
,
mlr_pipeops_multiplicityimply
,
mlr_pipeops_mutate
,
mlr_pipeops_nearmiss
,
mlr_pipeops_nmf
,
mlr_pipeops_nop
,
mlr_pipeops_ovrsplit
,
mlr_pipeops_ovrunite
,
mlr_pipeops_pca
,
mlr_pipeops_proxy
,
mlr_pipeops_quantilebin
,
mlr_pipeops_randomprojection
,
mlr_pipeops_regravg
,
mlr_pipeops_removeconstants
,
mlr_pipeops_renamecolumns
,
mlr_pipeops_replicate
,
mlr_pipeops_rowapply
,
mlr_pipeops_scale
,
mlr_pipeops_scalemaxabs
,
mlr_pipeops_scalerange
,
mlr_pipeops_select
,
mlr_pipeops_smote
,
mlr_pipeops_smotenc
,
mlr_pipeops_spatialsign
,
mlr_pipeops_subsample
,
mlr_pipeops_targetinvert
,
mlr_pipeops_targetmutate
,
mlr_pipeops_targettrafoscalerange
,
mlr_pipeops_textvectorizer
,
mlr_pipeops_threshold
,
mlr_pipeops_tomek
,
mlr_pipeops_tunethreshold
,
mlr_pipeops_unbranch
,
mlr_pipeops_updatetarget
,
mlr_pipeops_vtreat
,
mlr_pipeops_yeojohnson
Examples
library(mlr3)
library(mlr3learners)
task1 = tsk("iris")
g1 = LearnerClassifRpart$new() %>>% PipeOpRandomResponse$new()
g1$train(task1)
#> $randomresponse.output
#> NULL
#>
g1$pipeops$classif.rpart$learner$predict_type = "prob"
set.seed(2409)
g1$predict(task1)
#> $randomresponse.output
#> <PredictionClassif> for 150 observations:
#> row_ids truth response
#> 1 setosa setosa
#> 2 setosa setosa
#> 3 setosa setosa
#> --- --- ---
#> 148 virginica virginica
#> 149 virginica virginica
#> 150 virginica virginica
#>
task2 = tsk("mtcars")
g2 = LearnerRegrLM$new() %>>% PipeOpRandomResponse$new()
g2$train(task2)
#> $randomresponse.output
#> NULL
#>
g2$pipeops$regr.lm$learner$predict_type = "se"
set.seed(2906)
g2$predict(task2)
#> $randomresponse.output
#> <PredictionRegr> for 32 observations:
#> row_ids truth response
#> 1 21.0 23.76570
#> 2 21.0 21.28602
#> 3 22.8 27.52332
#> --- --- ---
#> 30 19.7 16.99001
#> 31 15.0 13.88306
#> 32 21.4 22.80808
#>