0

I have an R code which loads the RandomForest model, I am looking to create a function which

load(model)
randomforest_func = function(data) 
{
     data$pred = predict(model,data,type="prob")
     output = data.frame(data$customerid,data$pred[,2])
     return(output)
}

I need to make this function enabled in webserver, where an external application feeds data and retrieves the output.

The problem is, the model needs to be preloaded and cannot load into R env for each request.

The function needs to support parallel connections.

I tried installing opencpu in R.

The above code should be running in R and available at
http://localhost:1234/ocpu/

I now made changes to the opencpu.js to point to this URL and used the function in jquery to below. ocpu.r_fun_call("randomforest_func",parameters)

However this is seems to be not working..

Praveen K
  • 11
  • 3
  • so you've looked at …? and ran into …? snag and need help with …? piece of code that isn't working? – hrbrmstr Feb 18 '16 at 10:15
  • Step 1. Started R on windows Step 2. Library(opencpu) Step 3. Started Opencpu server Step 4. Ran the above the code to load randomforest model and ceate functions on R Step 5. Trying to change Opencpu.js which gets loaded to HTML page. At this stage the ocpu.r_fun_call cannot find the function random_forest defined in the function above i n step 4. Please help. – Praveen K Feb 18 '16 at 16:33
  • Possible duplicate of [Using OpenCPU to access custom R function](http://stackoverflow.com/questions/35501293/using-opencpu-to-access-custom-r-function) – Aramis7d Mar 10 '16 at 11:51

0 Answers0