1

I've trained a model using R, but now I am trying to deploy it in the current stack using NodeJS, I know that the model can be store as an RDS, but I'm not sure if I can use this model externally. Has anyone done this?

Necronet
  • 6,704
  • 9
  • 49
  • 89
  • 2
    Related discussions [here](https://community.rstudio.com/t/r-code-in-production-options/2015) and [here](https://stackoverflow.com/q/22309236/324364). The latter is fairly old, but based on SO conventions also probably dangerously close to a duplicate. – joran Jun 28 '18 at 22:03

2 Answers2

4

I think there are 2 answers.

The general case:

  1. No, this is not only data represented in an R format (.RDS) it's also only really a "model" when it's being interpreted by not even just R, but the R library running on R that trained the model (stats, caret, optimr, etc). So you could launch R from another language like NodeJS, but it will still need to hit R at some point in the process.

and the exception

  1. If you create a PMML model in R, you could export it and read it in another language, as that's universal.
Hack-R
  • 22,422
  • 14
  • 75
  • 131
  • Great answer! However, these days, one should use the `r2pmml` package (https://github.com/jpmml/r2pmml) for creating a PMML model in R, because it supports more model types, performs better and generates more correct/compact PMML documents. – user1808924 Jun 29 '18 at 14:05
  • @user1808924 Thanks! I will add the link to my answer – Hack-R Jun 29 '18 at 14:34
0

You can expose your model as a REST API and call it from any language

Luis Leal
  • 3,388
  • 5
  • 26
  • 49