Creating a Model using Script

This feature allows you to create models based on user-written scripts. The supported scripting languages are Standard R and ORE. The script should be valid.
In the case of the R script, all the object names used in the R-script should be syntactically valid. You should select Language as ORE if you are using ORE functions in the script. ORE enables transparent access to data stored in the Database for scalability and high performance. For more information, see Enterprise Modeling support for R Scripts and Oracle R Enterprise (ORE) Statistical Functions.
The models defined based on R scripting can be directly deployed to the Production Infodom without an execution in the sandbox.
To create a model using a script, follow these steps:
  1. Select the Add icon from the Model Management toolbar. The Model Definition window is displayed.

    Figure 9-4 Model Definition


    This image displays the Model Definition.

  2. Enter the model definition details. The common fields are described in table 8. For R scripted model, click to browse and upload .R file. You can use this option if you have already defined a technique and saved it in a .R file. Once uploaded successfully, the script is displayed in the Model Script pane.
    OR
    In the Model Script pane, enter the script for the model. For information on how to use fitting and prediction, see Fitting and Prediction Using R Script.

    Figure 9-5 Script Console


    This image displays the Script Console.

    Note:

    The format of the declaration and the content should not be altered. The scripting should start only from the line after the declaration block.
    By default, the Model Script is displayed as shown:
    • ## Variable --> Enter the variables you want to use in the script separated by commas.
    • ## Single Value Parameter --> Enter the input parameters you want to use in the script.
    • ## Model Input --> Enter the script variable names to which you want to load the output of another model in case of model chaining.
    • ## Output --> Enter the output parameters you want to use in the script.
    • ## Model Output--> Enter the object names you want to persist.
    The variables and input parameters are case-sensitive. The same name cannot be used for both variables and input parameters.
    You should explicitly define the outputs in the script that need to be updated back to tables. If the output is not defined, then the tables are not updated.
    For example :
    x = rbeta(100,1,2)
    y = rbeta(100,1,2)op = lm(y~x)
    If op$residuals needs to be updated then declare the output with a name.
    For Example:
    Residuals = op$residuals
    The grid below the Model Details section displays the various tabs available. To update the required information, see the following sections:
  3. Enter valid script of the model in the selected scripting language. For more information on data usage and data handling when R script and ORE functions are used, see R Scripts and Oracle R Enterprise (ORE) Statistical Functions.
  4. Click Save to save the model definition details, after all the necessary details are updated.
  5. Click Preview Data to view the data of the selected dataset. It displays the primary keys and the attributes/ columns of the tables in the selected dataset. Only those columns which are mapped to the variables in the script are displayed.

    Note:

    In the case of the Hive-based Sandbox information domain, previewing data takes a long time and only 100 records are displayed.
  6. Click Execute to execute the model.
    You can view the status of the model execution dynamically in the Execution Status grid.

    Note:

    Points about Model execution:
    • For R-based models, the execution may fail if the dataset contains internal joins.
    • Executing a model using the standard R engine with the new Cloudera jars is failing with model queries exceeding a certain limit. The workaround is to append UseNativeQuery=1 in the JDBC URL of the Hive schemas in which model definitions and executions happen. For example: jdbc:hive2:192.168.1.0:1000/default;useNativeQuery=1
    • Models executed using the Standard R engine will fail if multiple primary nodes are set in the ModelingFramework.XML
    • Users who are using ORE1.4.1 and R 3.1.1 may have to explicitly set session timezone in scripts registered within OFS EM by using the 'Sys.env(TZ=<time zone>)' R function. Alternatively, you may set the same call in the 'R_HOME/etc/Rprofile.site' file on the database server, where R_HOME is the home directory of the R instance on which ORE server packages are installed.
  7. Click Output to view the output. For more information, see the View Model Outputs section.