mllite/caret2sql

Add a web service for caret2sql

antoinecarme opened this issue · 2 comments

caret2sql is now prototyped using a local (evolving) version of the web service (https://github.com/antoinecarme/sklearn2sql_heroku).

The public web service can be updated to also include caret models (update web service name ?)

Deliverables :

Create a issue for sklearn2sql_heroku to include caret models, SQL generation and the necessary tests, sample R script etc

This work can be done as soon as possible to demonstrate the already implemented stuff in the issue #2

Sample R client using httr library for connecting to the web service. The model is serialized and sent, the result content contains the SQL code for deploying the model :

library(caret, quiet = TRUE)
library(base64enc)
library(httr, quiet = TRUE)

## multiclass classification on iris dataset:
    
dataset = as.matrix(iris[, -5])

model = train(Species ~ ., data = iris, method = "xgbTree")

WS_URL = "https://sklearn2sql.herokuapp.com/model"

model_serialized <- serialize(model, NULL)
b64_data = base64encode(model_serialized)

data = list(Name = "xgboost_test_model", SerializedModel = b64_data , 
               SQLDialect = "postgresql" , Mode="caret")

r = POST(WS_URL, body = data, encode = "json")
content = content(r)

lSQL = content$model$SQLGenrationResult[[1]]$SQL

cat(lSQL);

This is just an improvement of the existing sklearn2sql service. We added a new mode for activating caret support.

Otherwise, it is a almost proxy between scikit-learn and caret models (builds python models internally).