Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a web service for caret2sql #3

Closed
antoinecarme opened this issue Aug 4, 2018 · 2 comments
Closed

Add a web service for caret2sql #3

antoinecarme opened this issue Aug 4, 2018 · 2 comments

Comments

@antoinecarme
Copy link
Member

antoinecarme commented Aug 4, 2018

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

@antoinecarme
Copy link
Member Author

antoinecarme commented Aug 16, 2018

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);

@antoinecarme
Copy link
Member Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant