I'm pretty new in SAP World and I’m trying to work with R Server installed within SAP HANA Studio (Version of HANA Studio : 2.3.8 & Version of R Server 3.4.0)
My tasks are:
- Train the randomForest model on R Server within HANA Studio (with help of RLANG procedure on HANA)
- Save the randomForest model as PAL model object in HANA
- Make prediction on new data in HANA using this model
Here is a small example of RLANG procedure for training a saving the model on HANA:
PROCEDURE "PA"."RF_TRAIN" (
IN data "PA"."IRIS",
OUT modelOut "PA"."TRAIN_MODEL"
)
LANGUAGE RLANG
SQL SECURITY INVOKER
DEFAULT SCHEMA "PA"
AS
BEGIN
require(randomForest)
require(dplyr)
require(pmml)
# iris <- as.data.frame(data)
data(iris)
iris <- iris %>% mutate(y = factor(ifelse(Species == "setosa", 1, 0)))
model <- randomForest(y~Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, iris,
importance = TRUE,
ntree = 500)
modelOut <- as.data.frame(pmml(model))
END;
(Please don’t be confused, that I’m not using my input data for model training, this is not a real example)
Here is how a table with the model on SAP HANA should look like:
In this example training is working, but I’m not sure how to save the randomForest-Object on SAP HANA data base or how to convert the randomForest-Object into similar one in the picture.
Would appreciate any help :)