library(xgboost)
# load data
df = data.frame(ggplot2::diamonds)
head(df)
# data processing
out <- onehot2sql(df)
x <- out$model.matrix[,colnames(out$model.matrix)!='price']
y <- out$model.matrix[,colnames(out$model.matrix)=='price']
# model training
bst <- xgboost(x = x,
y = y,
max_depth = 3,
learning_rate = .3,
nrounds = 5,
nthreads = 1,
objective = 'reg:squarederror')
# generate model scoring SQL script with ROW_KEY and MODREADY_TABLE
booster2sql(bst)
Run the code above in your browser using DataLab