The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

R: Setting role of prediction does not work

fryasdffryasdf Member Posts: 7 Contributor II
edited November 2018 in Help
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)

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)
}
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).

Running this, in turn, does work:

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)
}
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?

Regards,

Fabian Werner,
Germany
Tagged:
Sign In or Register to comment.