R: Setting role of prediction does not work
fryasdf
New Altair Community Member
Hi.
I am trying to run an R script to compute a model and then verify the model. (All of this inside a [bigger] RM process) Now I want to be compliant with the data format in RapidMiner as I want to use the nice evaluation operators, etc, i.e. I want the role of the prediction to be, in fact, prediction :-)
This is my R-version of 'apply model': (offload is the variable Im trying to predict)
Running this, in turn, does work:
Regards,
Fabian Werner,
Germany
I am trying to run an R script to compute a model and then verify the model. (All of this inside a [bigger] RM process) Now I want to be compliant with the data format in RapidMiner as I want to use the nice evaluation operators, etc, i.e. I want the role of the prediction to be, in fact, prediction :-)
This is my R-version of 'apply model': (offload is the variable Im trying to predict)
This however does not work: It simply does not assign the role 'prediction' to the column 'prediction' in the data table 'final'... (without complains, without errors).
rm_main = function(model, data)
{
final = data[, .(offload)]
data = data[, offload := NULL]
dataAsMatrix = as.matrix(data)
# apply the model and build a prediction
result <-predict(model, dataAsMatrix)
# add the prediction to the example set
final$prediction <- result
final$prediction = (final$prediction >= 0.5)
# update the meta data
metaData$final$prediction <<- list(type="binomial", role="prediction")
return(final)
}
Running this, in turn, does work:
In short words: when I create a new, fresh data table and want to set the role then it does not work. When I continue to use the data table given, then it works... Is this a bug?
rm_main = function(model, data)
{
label = data[, .(offload)]
data = data[, offload := NULL]
dataAsMatrix = as.matrix(data)
# apply the model and build a prediction
result <-predict(model, dataAsMatrix)
# add the prediction to the example set
data$prediction <- result
data$prediction = (data$prediction >= 0.5)
data = data[, offload := label]
data = data[, .(offload, prediction)]
# update the meta data
metaData$data$prediction <<- list(type="binomial", role="prediction")
return(data)
}
Regards,
Fabian Werner,
Germany
0