## Not run:
# DB <- RODM_open_dbms_connection(dsn="orcl11g", uid= "rodm", pwd = "rodm")
#
# # Predicting survival in the sinking of the Titanic based on pasenger's sex, age, class, etc.
# data(titanic3, package="PASWR") # Load survival data from Titanic
# ds <- titanic3[,c("pclass", "survived", "sex", "age", "fare", "embarked")] # Select subset of attributes
# ds[,"survived"] <- ifelse(ds[,"survived"] == 1, "Yes", "No") # Rename target values
# n.rows <- length(ds[,1]) # Number of rows
# random_sample <- sample(1:n.rows, ceiling(n.rows/2)) # Split dataset randomly in train/test subsets
# titanic_train <- ds[random_sample,] # Training set
# titanic_test <- ds[setdiff(1:n.rows, random_sample),] # Test set
# RODM_create_dbms_table(DB, "titanic_train") # Push the training table to the database
# RODM_create_dbms_table(DB, "titanic_test") # Push the testing table to the database
#
# dt <- RODM_create_dt_model(database = DB, # Create ODM DT classification model
# data_table_name = "titanic_train",
# target_column_name = "survived",
# model_name = "DT_MODEL")
#
# dt2 <- RODM_apply_model(database = DB, # Predict test data
# data_table_name = "titanic_test",
# model_name = "DT_MODEL",
# supplemental_cols = "survived")
#
# print(dt2$model.apply.results[1:10,]) # Print example of prediction results
# actual <- dt2$model.apply.results[, "SURVIVED"]
# predicted <- dt2$model.apply.results[, "PREDICTION"]
# probs <- as.real(as.character(dt2$model.apply.results[, "'Yes'"]))
# table(actual, predicted, dnn = c("Actual", "Predicted")) # Confusion matrix
# library(verification)
# perf.auc <- roc.area(ifelse(actual == "Yes", 1, 0), probs) # Compute ROC and plot
# auc.roc <- signif(perf.auc$A, digits=3)
# auc.roc.p <- signif(perf.auc$p.value, digits=3)
# roc.plot(ifelse(actual == "Yes", 1, 0), probs, binormal=T, plot="both", xlab="False Positive Rate",
# ylab="True Postive Rate", main= "Titanic survival ODM DT model ROC Curve")
# text(0.7, 0.4, labels= paste("AUC ROC:", signif(perf.auc$A, digits=3)))
# text(0.7, 0.3, labels= paste("p-value:", signif(perf.auc$p.value, digits=3)))
#
# dt # look at the model details
#
# RODM_drop_model(DB, "DT_MODEL") # Drop the model
# RODM_drop_dbms_table(DB, "titanic_train") # Drop the database table
# RODM_drop_dbms_table(DB, "titanic_test") # Drop the database table
#
# RODM_close_dbms_connection(DB)
# ## End(Not run)
Run the code above in your browser using DataLab