Exporting the Final Model to Build the Scoring Application

In this section:

Once you have finalized your model, you can export the model formula as a routine that can be used to score new data outside of RStat.

RStat offer two types of export options:


Top of page

x
Exporting Using C or PMML

How to:

You can export data using C or PMML. You use C so that the data will work with WebFOCUS and you use PMML in order to see the XML output of the model (or meta) information.



x
Procedure: How to Export Using C or PMML

You can use this procedure to export using C or PMML.

  1. Select the Model tab, as shown in the following image.

    Model tab

    If you have executed multiple models, make sure that the specific model you would like to export is selected.

  2. Click Export from the RStat toolbar. The Export dialog box opens, as shown in the following image.

    Export dialog box

  3. Select C Files or PMML Files from the Type drop-down list to view existing files of the selected type within the current path.

    Tyoe drop-down list

  4. Select an Include option. These allow you to selectively include the PMML and Model Metadata in the C routine for further reference. They are embedded as text strings within the routine, which can be extracted using the RStat command in WebFOCUS (see Displaying Model Information With the RStat Query Command). Depending on the model you have built, these text strings can be very large. In certain environments, you will want to exclude these because they will be too large to successfully compile. Options include:
    • PMML. Includes the PMML within the routine.
    • Meta Data. Includes key model metadata within the routine. This is the model output from R which appears on the Model Textview on the Model Tab, as highlighted in the following image.

    Note: Clear the check box next to either of these include options to exclude these from the exported routine.

  5. Select Teradata UDF to export scoring functions contained within C files to be consumed as a Teradata User Defined Function (UDF). For more information, see RStat Export for Teradata User Defined Function.
  6. Click Save.The file containing your scoring routine will be generated and placed in the selected location and file name.

Top of page

x
RStat Export for Teradata User Defined Function

How to:

As of RStat Version 1.3.1, you can export Scoring functions contained within C files to be consumed as a Teradata User Defined Function (UDF). With the exception of the Teradata Export option, the export process is similar to the regular RStat export.

For Big Data Analytics, RStat routines can be deployed for in-database execution. This means that the actual scoring of large amounts of data is executed in the database engine, alleviating the need for extracting the data prior to scoring. When scoring large amounts of data, running the predictive model as an in-database function may result in significant performance gains.



x
Procedure: How to Create a C File for a Teradata User Defined Function

After creating the predictive model, from the Export tab, select the Teradata UDF option on the Export dialog box and then Execute. A C file is created in Teradata UDF format, along with the SQL template needed to define the C program to Teradata. All the input fields are automatically defined in the SQL template. However, the actual location of the C file that has been uploaded needs to be modified in the SQL template. Once you have the location and the SQL, the UDF creation process defined by Teradata should be followed.

Once defined as a Teradata UDF, the RStat model can then be defined as an in-database function to WebFOCUS, either at the Metadata or the WebFOCUS procedure level.

The power of an RStat predictive model in-database function means that you can easily incorporate the model into ETL, reporting, Dashboard, or any other native Teradata Client application.

  1. Source the data, as shown in the following image.

  2. Run the model to be exported, as shown in the following image.

  3. Export the Scoring routine as a C file and select the Teradata UDF option from the Export screen, as shown in the following image.

    Along with the C file, an SQL template is created. The items in << item>> need to be modified in the line below:

    << ENTER FULL PATH OF UDF C FILE HERE AND PUT IN SINGLE QUOTE >>
        EXAMPLE 'CS!<<model name>>!/home/testdrive/ibi/apps/<<model name>>.c!F! <<model name>>'

    The following image show an SQL template that has been modified and pasted into a Basic Teradata Query (BTEQ) tool to create a Teradata UDF.

    Using the UDF in an SQL Select, note that the custscore function name matches the C file deployment in Teradata.

    The following image shows in-database scored values (Arrows) returned in a report.

    RStat models are completely integrated with Information Builders tools. Using predictive models in ETL allows you to segment data based on customer market segmentation.


WebFOCUS