7.1.2 About In-Database Model Names and Renaming with OML4R Functions

In each OREdm R model object, the slot name is the name of the underlying OML4SQL model generated by the OREdm function.

By default, models built using OREdm functions are transient objects; they do not persist past the R session in which they were built unless they are explicitly saved in an OML4R datastore or specified with an explicit name when created. OML4SQL models built using Data Miner or PL/SQL API, on the other hand, exist until they are explicitly dropped.

R proxy objects can be saved or persisted. Saving a model object generated by an OREdm function allows it to exist across R sessions and keeps the corresponding in-database machine learning model object in place. While the OREdm model exists, you can export and import the in-database model object and use it independent of the OML4R object.

You can use the MODEL_NAME parameter in odm.settings to explicitly name an in-database model object created in the database. The named in-database model object persists in the database just like those created using Oracle Data Miner or PL/SQL.

Example 7-1 Using MODEL_NAME parameter to explicitly name in-database model proxy object

This example demonstrates building a Random Forest Model and naming the model using explicit settings. The example uses the MODEL_NAME parameter in odm.settings to explicitly name an in-database model object created in the database.

ore.drop(model='RF_CLASSIFICATION_MODEL')
settings = list(RFOR_MTRY = 3, model_name="RF_CLASSIFICATION_MODEL")
MOD2 <- ore.odmRF(AFFINITY_CARD~., DEMO_DF.train, odm.settings= settings)
MOD2$name
Listing for This Example
'RF_CLASSIFICATION_MODEL'

In the above code, the model named RF_CLASSIFICATION_MODEL should be dropped if it already exists because it will throw an exception while we try to build a model with the same name. The In-database Random Forest Classification model named RF_CLASSIFCIATION_MODEL is built using the specified settings and the model is referenced by the variable MOD2.

While the R model exists or if you have assigned the model a user-specified name, use the OML4SQL model name to access the OML4SQL model through other interfaces, including:

  • Any SQL interface, such as SQL*Plus or SQL Developer

  • Oracle Data Miner

In particular, the model can be used with the OML4SQL prediction functions.

With Oracle Data Miner you can do the following:

  • Get a list of available models

  • Use model views to inspect model details

  • Score appropriately transformed data

Note:

Any explicit user-performed transformations in the R space are not carried over into SQL scoring or Oracle Data Miner. Users can also get a list of models using SQL for inspecting model details or for scoring appropriately transformed data.