R/applyLearner.R

Defines functions applyLearner

Documented in applyLearner

applyLearner <-
function(learner,X){
  leftIx <- 1:nrow(X)
  predY <- rep("",nrow(X))
  for(i in 1:nrow(learner)){
    ixMatch <- eval(parse(text=paste("which(",learner[i,"condition"], ")"))  ) 
    ixMatch <- intersect(leftIx,ixMatch)
    if(length(ixMatch)>0){
      predY[ixMatch] <- learner[i,"pred"]
      leftIx <- setdiff(leftIx,ixMatch)
    }
    if(length(leftIx)==0){
      break
    }
  }
  return(predY)
}

Try the inTrees package in your browser

Any scripts or data that you put into this service are public.

inTrees documentation built on June 1, 2022, 1:06 a.m.