Model Deployed in BucketFS R Regression Example

kaanmutlu
Contributor

Hi All,

I have a question regarding the advanced analytic example in this article.

In the example, it says that “we will use the model stored in BucketFS” but actually I am also interested in the model itself.

So by there any chance that any developer can share the model stored in BucketFS with me?

Or the code that is used for building the machine learning model would also be enough for me.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

exa-Valerie
Team Exasol
Team Exasol

Hello Kaan,

the model was trained via random forrest, here is the example code how it could be trained in R Studio:

# build a model for testing

#install packages
install.packages('exasol') 
install.packages('randomForest')
install.packages('RCurl')

# see www.github.com/exasol/r-exasol
library(exasol)

#
# Get sample data
#
con <- dbConnect(
  drv     = "exa",                  # EXAdriver object
  exahost = "localhost:48563",  # IP of database cluster
  uid     = "<my_user>",                  # Username
  pwd     = "<my_pwd>")               # Password



df <- dbGetQuery(con, "SELECT AIRLINE_ID, FLIGHTNUM, DAYOFWEEK, DEPDELAY from FLIGHTS.OTP LIMIT 250000")
dbDisconnect(con)

#
# Train the random forest model
#
library(randomForest)
set.seed(852)
df <- df[complete.cases(df),]
model1 <- randomForest(DEPDELAY ~ AIRLINE_ID + FLIGHTNUM + DAYOFWEEK, data=df)

If you already created a bucket on your Exasol node, you can directly upload the model to the Exasol cluster using curl:



library(RCurl)
curl_opts = curlOptions(userpwd  = "w:<write_password>",
                        verbose  = FALSE,
                        httpauth = AUTH_BASIC)
httpPUT(
  url = "http://localhost:2580/predictive_r/flight_model",
  content = serialize(model1, ascii = TRUE, connection = NULL),
  curl = getCurlHandle(.opts = curl_opts)
)

Does this help?

Valerie

 

View solution in original post

2 REPLIES 2

exa-Valerie
Team Exasol
Team Exasol

Hello Kaan,

the model was trained via random forrest, here is the example code how it could be trained in R Studio:

# build a model for testing

#install packages
install.packages('exasol') 
install.packages('randomForest')
install.packages('RCurl')

# see www.github.com/exasol/r-exasol
library(exasol)

#
# Get sample data
#
con <- dbConnect(
  drv     = "exa",                  # EXAdriver object
  exahost = "localhost:48563",  # IP of database cluster
  uid     = "<my_user>",                  # Username
  pwd     = "<my_pwd>")               # Password



df <- dbGetQuery(con, "SELECT AIRLINE_ID, FLIGHTNUM, DAYOFWEEK, DEPDELAY from FLIGHTS.OTP LIMIT 250000")
dbDisconnect(con)

#
# Train the random forest model
#
library(randomForest)
set.seed(852)
df <- df[complete.cases(df),]
model1 <- randomForest(DEPDELAY ~ AIRLINE_ID + FLIGHTNUM + DAYOFWEEK, data=df)

If you already created a bucket on your Exasol node, you can directly upload the model to the Exasol cluster using curl:



library(RCurl)
curl_opts = curlOptions(userpwd  = "w:<write_password>",
                        verbose  = FALSE,
                        httpauth = AUTH_BASIC)
httpPUT(
  url = "http://localhost:2580/predictive_r/flight_model",
  content = serialize(model1, ascii = TRUE, connection = NULL),
  curl = getCurlHandle(.opts = curl_opts)
)

Does this help?

Valerie

 

View solution in original post

kaanmutlu
Contributor

Hi Valerie,

Thank you so much for sharing the model 👍