IBM DB2 Intelligent Miner Scoring

Administration and
Programming for Oracle

Version 8.2
SH12-6746-01
Note

Before using this information and the product it supports, be sure to read the information in Appendix F. Notices.

Second Edition, August 2004

This edition applies to Version 8.2 of IBM DB2 Intelligent Miner Scoring, program number 5765-F36, and to all subsequent releases and modifications until otherwise indicated in new editions.

This edition replaces SH12-6746-00.

Copyright International Business Machines Corporation 2001, 2004. All rights reserved.
US Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

Contents

Figures
Tables
About this book
Who should use this book
Conventions and terminology used in this book
How this book is structured
How to read the syntax diagrams
How to send your comments
What is new in version 8.2
Improved model interoperability
Functional enhancements
Standards conformance
Consistency notices
User's guide
Introducing the Intelligent Miner products
IBM DB2 Intelligent Miner Scoring
IBM DB2 Intelligent Miner Modeling
IBM DB2 Intelligent Miner Visualization
IBM DB2 Intelligent Miner for Data
Introducing IM Scoring
Introducing data mining functions
Associations
Classification
Clustering
Regression
PMML: A markup language for data mining
Sources of PMML models
PMML models created by IM for Data
PMML models created by vendor tools
Deployment scenarios
Introducing the SQL/MM API
Familiarizing yourself with the SQL API
Introducing SQL statements for scoring
Quick start using the sample applications
Creating database objects
Generating SQL scripts from your own mining models
Sample files
Completing the practice exercises
Creating a table and importing data
Creating sample tables for mining models and importing a model
Applying a model and getting results values
Extracting information from a model
Using IM Scoring Java Beans to score records
Using idmmkSQL to work with your own mining models
Using IM Scoring
Scoring data types and functions
User-defined data types
User-defined functions
Creating database objects
Enabling databases
Disabling databases
Deploying mining models
Exporting models from IM for Data
Converting exported models
Importing mining models
Generating SQL statements from models
Extracting information from a model
Applying mining models
Using the application functions
Specifying data by means of DM_ApplRow and DM_ApplColumn
Specifying data by means of DM_applData
Specifying data by means of CONCAT
Comparing DM_applData, CONCAT, and DM_ApplRow / DM_ApplColumn
Results data
Getting application results
Handling missing values
Using the model cache for real-time scoring
Performance considerations
Using IM Scoring Java Beans
Setting environment variables
Specifying the mining model to be used
Accessing model metadata
Specifying a data record
Using the Java Single Record Scorer
Applying scoring
Accessing computed results
Scoring example
ScoringException classes
Reference
Utility functions provided by IM Scoring
Data types reference
Functions and stored procedures reference
DM_applData
DM_applyClasModel
DM_applyClusModel
DM_applyRegModel
DM_expClasModel
DM_expClusModel
DM_expDataSpec
DM_expRegModel
DM_getClasCostRate
DM_getClasMdlName
DM_getClasMdlSpec
DM_getClasTarget
DM_getClusConf
DM_getClusMdlName
DM_getClusMdlSpec
DM_getClusMdlType
DM_getClusScore
DM_getClusterID
DM_getClusterName
DM_getConfidence
DM_getFldName
DM_getFldType
DM_getNumClusters
DM_getNumFields
DM_getPredClass
DM_getPredValue
DM_getQuality
DM_getQuality(clusterid)
DM_getRBFRegionID
DM_getRegMdlName
DM_getRegMdlSpec
DM_getRegTarget
DM_impApplData
DM_impApplDataLarge
DM_impClasFile
DM_impClasFileE
DM_impClasModel
DM_impClusFile
DM_impClusFileE
DM_impClusModel
DM_impDataSpec
DM_impRegFile
DM_impRegFileE
DM_impRegModel
DM_isCompatible
PredictClass
PredictClassConf
PredictClusConf
PredictClusterID
PredictClusQuality
PredictClusScore
PredictValue
IM Scoring utilities reference
DM_initialize
DM_memoryFree
DM_printenv
DM_printModelCache
DM_setEnv
Command reference
The idm_setup command
The idm_uninstall command
The idmlevel command
The idmlicm command
The idmmkSQL command
The idmxmod command
Administration
Getting error information
Getting support
Problem identification worksheet
Getting product information
Getting trace information
Tracing errors
Migrating from IM Scoring V7.1
Working with IM Scoring V7.1 and V8.2 in parallel
Exporting and importing models with the use of compression
Applying Neural models
Using the function DM_getClusterID
Migrating from IM Scoring Version 8.1
Appendixes
Appendix A. IM Scoring conformance to PMML
IM Scoring application
IM Scoring conversion tools
Regression models
Features supported in addition to PMML 2.1
Appendix B. SAS Enterprise Miner support
Appendix C. SPSS Clementine support
Appendix D. Using IM Scoring in a multilanguage environment
Appendix E. Encoding considerations when exporting models
Appendix F. Notices
Trademarks
Bibliography
IBM DB2 Intelligent Miner publications
Oracle publications
Related information
IBM Web sites
Other Web sites
Index

Figures

  1. IM Scoring overview
  2. The IM Scoring process
  3. Scoring data types and syntax
  4. Model import processes
  5. Applying a model to data
  6. Architecture sample to realize a call-center scenario
  7. User options

Tables

  1. Formatting conventions
  2. Abbreviations
  3. PMML model types, mining functions, and mining algorithms
  4. Sample files for the Clustering mining function of IM Scoring
  5. Sample files for IM Scoring Java Beans
  6. Import functions and related data types and tables
  7. Import functions using a specific XML encoding
  8. Import functions using CLOB values
  9. Functions for applying models
  10. Application functions and their data types and results data
  11. Results functions and their purpose (Clustering model)
  12. Results functions and their purpose (Classification model)
  13. Results functions and their purpose (Regression model)
  14. IM Scoring Java Beans methods for accessing model metadata
  15. IM Scoring Java Beans methods for accessing computed results
  16. Utility functions specific to IM Scoring
  17. Data types specific to IM Scoring
  18. Mining field types

About this book

IBM(R) DB2(R) Intelligent Miner(TM) Scoring is an application that integrates the model application functionality of Intelligent Miner for Data with the Oracle database.

Intelligent Miner Scoring enables you to import and apply mining models, and to access the results.

Throughout this book, the following abbreviations are used:

This book describes how to use IM Scoring and IM Scoring Java Beans. It also provides a full reference resource to the database objects provided by IM Scoring.

For more information on:

Who should use this book

This book is intended for the following users:

Conventions and terminology used in this book

In Oracle, the names of the scoring functions, data types, tables, and table columns are created in uppercase letters, even if you used, for example, lowercase letters. In this book, these names are represented in mixed case for better readability.

The following table shows the formatting conventions used in this book.

Table 1. Formatting conventions
Convention used How it is used
Interface elements, for example, menu bars, buttons, and labels are shown in boldface. Click OK.
Menu instructions are shown in boldface and sequential instructions are separated by arrows. Click File --> Export.
Command syntax is shown in a monospaced font. idm_setup.bat
The names of the following are shown in a monospaced font:
  • Files and directories
  • Database tables and columns
  • SQL functions and data types
The SQL INSERT command inserts the model into a column of the table CLUSTERMODELS, which is configured for the data type DM_ClusteringModel.
Variables within syntax descriptions, which you should replace by a real value, are shown in italics. If they consist of more than one word they are placed between angle brackets. idmdisabledb <db name>
Italics are used to highlight the introduction of a new term. These functions are also referred to as user-defined functions and to indicate that a variable should be replaced.

The following table shows the abbreviations used in this book.

Table 2. Abbreviations
Abbreviation Full form
CRM Customer Relationship Management
GUI Graphical user interface
ICU International Components for Unicode
PMML Predictive Model Markup Language
RBF Radial Basis Function
RPM Redhat Package Manager
SQL Structured Query Language
UDF User-defined function
UDT User-defined data type
XML Extensible Markup Language

How this book is structured

This book is divided into the following parts:

User's guide
Contains the following:
Reference
Provides a reference resource to all the IM Scoring database objects and utilities.
Administration
Provides information on how to administer, diagnose, and migrate IM Scoring.

The appendixes provide reference information.

How to read the syntax diagrams

In the reference part of this book, the syntax for IM Scoring's functionality is described using the following structure:

How to send your comments

Your feedback is important in helping us to provide you with the most accurate and high-quality information possible. If you have any comments about this book:

What is new in version 8.2

This section introduces you to the new features in IM Scoring.

Improved model interoperability

You can import additional data mining models in PMML format, for example, created by SAS EM or SPSS Clementine. The export and import of PMML models is easier than before. Other programs, such as SAS EM and SPSS Clementine allow to directly import PMML models from their workbenches. For more information refer to:

Functional enhancements

Improved error detection
During model import errors are checked and identified.
Model caching
Models that are read from the database and then used in a scoring function are now cached in memory. This avoids a reloading and reparsing of the model in a subsequent SQL statement within the same database session. This improves the performance, especially if many SQL statements are run that use the same model and each model scores only a few records. Up to two models can be cached. Model caching allows real-time scoring using the SQL interface of IM Scoring. For details, see Using the model cache for real-time scoring.
Support for Regression models produced by IM Modeling
IM Scoring supports Transform Regression models. Transform Regression is a new regression algorithm introduced with the new easy mining capabilities of IM Modeling. For more information refer to DB2 Intelligent Miner Modeling: Administration and Programming.
Read the mining model from an Oracle table
The Java Record Scorer API has been extended to read the mining model not just from a file, but also from an Oracle table. For details, see Specifying the mining model to be used.

Standards conformance

PMML 2.1 support
IM Scoring can read, store, and use PMML models up to Version 2.1. Its conversion utilities can also generate PMML 2.1 models. For more information refer to Appendix A. IM Scoring conformance to PMML.
SQL/MM
IM Scoring adheres to the SQL Multimedia (SQL/MM) standard, which is an International Standard for data mining. The standard is developed by ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission), who together form a specialized system for worldwide standardization.

The standards for data mining are outlined in ISO/IEC 13249; the description appears in Part 6: Data Mining of the standards specification. This specification has the general title Information technology - Database languages - SQL Multimedia and Application Packages.

Consistency notices

You should consider the following consistency notices when using IM Scoring V8.2:

User's guide

Introducing the Intelligent Miner products
IBM DB2 Intelligent Miner Scoring
IBM DB2 Intelligent Miner Modeling
IBM DB2 Intelligent Miner Visualization
IBM DB2 Intelligent Miner for Data
Introducing IM Scoring
Introducing data mining functions
Associations
Classification
Clustering
Regression
PMML: A markup language for data mining
Sources of PMML models
PMML models created by IM for Data
PMML models created by vendor tools
Deployment scenarios
Introducing the SQL/MM API
Familiarizing yourself with the SQL API
Introducing SQL statements for scoring
Quick start using the sample applications
Creating database objects
Generating SQL scripts from your own mining models
Sample files
Completing the practice exercises
Creating a table and importing data
Creating sample tables for mining models and importing a model
Applying a model and getting results values
Getting the values of the calculated results
Storing scoring results permanently
Extracting information from a model
Using IM Scoring Java Beans to score records
Using idmmkSQL to work with your own mining models
Using IM Scoring
Scoring data types and functions
User-defined data types
User-defined functions
Creating database objects
Enabling databases
Disabling databases
Deploying mining models
Exporting models from IM for Data
Converting exported models
Importing mining models
Importing mining models from a file
Importing mining models from a file using a specific XML encoding
Importing mining models from a CLOB value in a database table
Generating SQL statements from models
Extracting information from a model
Applying mining models
Using the application functions
Specifying data by means of DM_ApplRow and DM_ApplColumn
Specifying data by means of DM_applData
Specifying data by means of CONCAT
Comparing DM_applData, CONCAT, and DM_ApplRow / DM_ApplColumn
Results data
Getting application results
Handling missing values
Using the model cache for real-time scoring
Performance considerations
Using IM Scoring Java Beans
Setting environment variables
Specifying the mining model to be used
Accessing model metadata
Specifying a data record
Using the Java Single Record Scorer
Applying scoring
Accessing computed results
Scoring example
ScoringException classes

Introducing the Intelligent Miner products

The IBM DB2 Intelligent Miner is a set of the following products:

These products provide rapid enablement of IM analytics that are embedded in Business Intelligence (BI), eCommerce, or traditional Online Transaction Processing (OLTP) application programs. They are available as separately priced products. They are also available in the IBM DB2 Data Warehouse Edition, except for IM for Data.

IM Scoring and IM Modeling constitute a software development kit (SDK). They consist of Oracle cartridges (IM Scoring only) or DB2 extensions that include an SQL API. You can embed the SQL API in business applications to exploit the data mining functions from this business application.

In Oracle, professionals can interactively issue SQL statements from the Oracle Enterprise Manager or from SQL*Plus. They can also start Intelligent Miner functions from one of these interfaces.

Depending on the experience, the personal preferences, the mining skills, and the complexity of the problem to solve, you can choose between the following approaches to develop a mining solution:

IBM DB2 Intelligent Miner Scoring

IM Scoring provides scoring technology as database extenders, DB2 extenders, and Oracle cartridges. It enables application programs to apply PMML models to large databases, subsets of databases, or single rows or cases. Application programs use the SQL API, which consists of user-defined functions (UDFs) to perform the scoring operation. The PMML models might have been created by one of the Intelligent Miner products or by other applications and tools that support PMML models.

The following table shows the different PMML models that can be applied by different mining algorithms.

Table 3. PMML model types, mining functions, and mining algorithms
Data mining function PMML model type Mining algorithm Generated by IM for Data Generated by IM Modeling
Clustering Center-based clustering Center-based Clustering algorithm yes no
Distribution-based clustering Distribution-based Clustering algorithm yes yes
Classification Neural networks Neural Classification algorithm yes no
Decision tree Tree Classification algorithm yes yes
Regression Logistic Regression algorithm no no
Regression Regression Linear Regression algorithm yes no
composite MiningModel (see Notes) Transform Regression algorithm no yes
Proprietary XML RBF Prediction algorithm yes no
Neural networks Neural Regression algorithm yes no
Notes:
  1. IM Scoring supports models that are built by the RBF Prediction algorithm of the Intelligent Miner for Data. These models are not yet part of PMML. You can export these models in XML format from the Intelligent Miner for Data and use them with IM Scoring.
  2. Mining models that are applied by the SQL API of IM Scoring must be contained in database tables.
  3. Transform Regression models created by IM Modeling are not fully PMML 2.1 compliant models. They use existing PMML 2.1 element names with several minor additions. These additions have been submitted to be part of the next PMML 3.0 standard.

IM Scoring includes IM Scoring Java Beans, which enables you to score a single data record in a Java application given a PMML model. This can be used to integrate scoring in e-business applications, for example, for real-time scoring in customer relationship management (CRM) systems.

IBM DB2 Intelligent Miner Modeling

IM Modeling provides IM Modeling technology as DB2 extenders. It enables SQL application programs to develop analytic models based on data accessed by DB2 Universal Database(TM) Version 8.1 or Version 8.2 SQL. Using the SQL API, you can build Associations, Distribution-based Clustering, Tree Classification, and Transform Regression PMML models that are stored in DB2 tables. They can be processed by IM Scoring or IM Visualization.

IM Modeling is easy to understand for users who are familiar with the mining functions in IM for Data.

Note:
IM Modeling is not available for the Oracle platform.

IBM DB2 Intelligent Miner Visualization

IM Visualization provides the following JAVA visualizers to present data modeling results for analysis:

You can use the Intelligent Miner Visualizers to visualize PMML-conforming mining models. Applications can call these visualizers to present model results, or you can deploy the visualizers as applets in a Web browser for ready dissemination. The models might have been developed by using IM Modeling or other applications and tools that support interoperability through the use of PMML models, or models of the Intelligent Miner for Data might have been exported as PMML models. Models are stored as flat files, or you can directly visualize mining models from the database. The models in the database have been created by IM Modeling or they have been imported into the database using the import functions of IM Scoring.

The focus of the PMML standard is interoperability for scoring. The best results with IM Visualization can be achieved if the PMML models contain IM Visualization extensions such as distribution statistics or quality information as produced by IM Modeling. For more information on IM Visualization extensions contact your IBM representative.

IM Visualization Version 8.2 provides the following enhancements:

The Intelligent Miner Visualizers Version 8.1 are also included in Intelligent Miner for Data Version 8.1.

IBM DB2 Intelligent Miner for Data

Intelligent Miner for Data Version 8.1 is an independent product that provides the following mining functions to build and apply mining models based on database or flat file data:

IM for Data Version 8.1 is a stand-alone data mining application (workbench) for end users and primarily statisticians with advanced data mining skills. It includes the Intelligent Miner Visualizers and the PMML conversion component of IM Scoring, which allows you to export mining models in PMML format.

Introducing IM Scoring

This chapter introduces you to the general concepts you need to know to work with IM Scoring. IM Scoring is an add-on service to Oracle that extends the capabilities of Oracle to include data mining functions. Mining models are built using:

IM Modeling
This provides mining models in PMML format that are directly stored in DB2.
IM for Data
This produces models that can be exported as PMML models.
Other tools
Any other tool that provides mining models in PMML format, such as SAS Enterprise Miner (SAS EM) or SPSS Clementine.
Note:
For more information on PMML support refer to Appendix A. IM Scoring conformance to PMML.

You use IM Scoring as follows:

  1. Import or load a mining model into an Oracle table.
  2. Apply the model to data within Oracle and optionally store scoring results in a database table.
  3. Access the results. These scoring results can have different contents. IM Scoring provides functions to retrieve the values of scoring results.

The model is stored in the database in a standardized XML format (PMML). You can directly visualize the mining model from the database using IM Visualization in stand-alone mode or as a Web applet. You can use IM Scoring to apply the model to new data.

Figure 1 shows that PMML models can be applied to new rows of data (ApplicationData) using the Scoring Apply function, which computes a scoring Result that contains the scores and predictions.

Figure 1. IM Scoring overview
IM Scoring overview

Introducing data mining functions

This section introduces you to the different data mining functions that are supported by IM Scoring. These data mining functions contain different PMML model types and mining algorithms. Each model type includes different algorithms to deal with the individual data mining functions.

For example, the Clustering data mining function includes the PMML model types Distribution-based Clustering and Center-based Clustering. The scoring functions for Clustering include the Distribution-based Clustering algorithm and the Center-based Clustering algorithm.

IM Scoring supports the data mining functions provided by:

Notes:
  1. IM Scoring supports only the application of these models.
  2. An overview of the data mining functions, PMML model types, and mining algorithms is provided in Table 3.

Associations

The Associations mining function finds items that are consistently associated with each other in a meaningful way. For example, you can analyze purchase transactions to discover combinations of goods that are often purchased together. The Associations mining function answers the question: If certain items are present in a transaction, what other item or items are likely to be present in the same transaction?

Note:
IM Scoring does not support the application of Associations models.

Classification

Classification is the process of automatically creating a model of classes from a set of records that contain class labels. The classification technique analyzes records that are already known to belong to a certain class, and creates a profile for a member of that class from the common characteristics of the records. You can then use a data mining application tool to apply this model to new records, that is, records that have not yet been classified. This enables you to predict if the new records belong to that particular class.

When a model is applied, IM Scoring assigns a class label and a confidence value to each individual record being scored.

Clustering

The clustering technique consists of a range of algorithms that group data records on the basis of how similar they are. For example, a data record might consist of a description of customers. In this case, clustering would group similar customers together, and at the same time it would maximize the differences between the different customer groups formed in this way. The groups that are found are known as clusters. Each cluster tells a specific story about customer identity or behavior, for example, about their demographic background, or about their preferred products or product combinations. In this way, customers can be grouped in homogeneous groups that are very similar to each other.

When a model is applied, IM Scoring assigns a cluster ID, a cluster score, a quality value, and a confidence value to each individual record being scored. The cluster score, quality value, and confidence value are different measures that indicate how well the record fits into the assigned cluster.

Regression

Regression is similar to classification except for the type of the predicted value. Rather than predicting a class label, regression is predicting a numeric value. Furthermore, regression can determine which input fields are most relevant to predict the target field values. The predicted value might not be identical with any value contained in the data used to build the model. An example application is customer ranking by expected profit.

When a model is applied, IM Scoring assigns a predicted value and, for an RBF model, a region ID to each individual customer being scored.

PMML: A markup language for data mining

PMML is a standard format for data mining models. Based on XML, the PMML format provides a standard that enables data mining models to be shared between the applications of different vendors. The intention is to provide a vendor-independent method for defining models. In this way, proprietary issues and incompatibilities are no longer a barrier to the exchange of models between applications.

For more information on PMML support refer to Appendix A. IM Scoring conformance to PMML.

Sources of PMML models

IM Scoring applies PMML models to data in the database. The PMML models are stored as binary large objects (BLOBs) in the database. IM Scoring provides UDFs to import models into the database.

You can use the following sources of PMML models:

This section describes the tools that can create PMML models for IM Scoring.

Note:
IM Modeling is not described here because it is available for DB2 only. However, you can export mining models from DB2 that have been created with IM Modeling and import them into an Oracle database.

PMML models created by IM for Data

You can use IM for Data to build and store models for all mining functions that are supported as shown in Table 3.

To migrate IM for Data models, you can:

Figure 2 shows the process by which a mining model that was built with IM for Data is exported from IM for Data, imported into an Oracle database, and applied to selected data. To use the IM Scoring mining functions:

Figure 2. The IM Scoring process
The IM Scoring process

PMML models created by vendor tools

The mining technology is based on open standards like SQL/MM, PMML, and XML. Other products, such as SAS EM and SPSS Clementine, allow to directly export PMML models from their workbenches. These models can then be imported into the database using the import functions of IM Scoring. For more information refer to:

Deployment scenarios

Depending on your real-time requirements you can invoke the Scoring apply function in different ways. It is important to consider how often the data to be scored changes and how often you need to recompute the scores.

Batch scoring with persistent results
The most efficient way to compute scores is to apply the scoring function to all records of a table in batch mode. In this case the scoring result object (or individual values from a scoring result) is stored persistently in a table using the INSERT statement. Use this approach if you want to:

See Storing scoring results permanently for an example of batch scoring with persistent results.

Batch scoring from a view
In this case you create a scoring result VIEW. The view definition contains the scoring apply function. In this case the scoring results are recomputed whenever you SELECT from the view. Using a VIEW saves you from computing a score for all records because the scores are only computed for the records actually retrieved. Use this approach if: See Creating a table and importing data and Getting the values of the calculated results for an example of scoring from a view.
Triggered scoring
You can include the scoring apply function in the definition of an INSERT or UPDATE trigger that recomputes a persistent scoring result, whenever a record is inserted or changed. Using a trigger allows to move the business rules from the applications into the database. Use this approach if: You can combine this approach with BATCH scoring. When loading the table in a batch window, compute all scores in batch mode. For data changes that trickle in between batch updates use triggered scoring.
Real-time scoring of individual records
In this scenario the record to be scored is created by an application and a score must be computed at once. A typical example is a call-center or retail point-of-sale application where new data about a customer becomes available and a cross-selling recommendation must be computed in real time.

In this case you have the following options:

Introducing the SQL/MM API

Here you find a general introduction to the SQL/MM API terminology and statements.

Familiarizing yourself with the SQL API

The SQL/MM API is a standardized open SQL API, that:

The following list familiarizes you with the SQL API terminology:

LogicalDataSpec
Describes the logical schema of input table
Model
Describes the rules and patterns found in the modeling phase
ApplicationData
Describes the row data record provided for scoring
Result
Describes the scores computed in scoring

Introducing SQL statements for scoring

Figure 3 maps the conceptual objects to the user-defined types (UDTs) used in IM Scoring. This figure shows an example for clustering.

Figure 3. Scoring data types and syntax
Scoring data types and syntax

In Figure 3 the Scoring function DM_applyClusModel receives the following parameters:

As the scores are computed in a scalar user-defined function, the scoring step can be embedded in arbitrary SQL statements.

Example: Apply a Clustering model to determine the customer segment for each customer in table BANKING_SCORING. This example joins the BANKING_SCORING table containing the data rows and the model table CLUSTERMODELS. The model BLOB with MODELNAME 'DemoBanking' is read from table CLUSTERMODELS explicitly:

CREATE OR REPLACE VIEW CLUSTERVIEW (CLUSTER_RESULT) AS 
  SELECT IDMMX.DM_applyClusModel(C.MODEL, 
           IDMTY.DM_ApplRow( 
           IDMTY.DM_ApplColumn('TYPE', B.TYPE, NULL), 
           IDMTY.DM_ApplColumn('AGE', NULL, B.AGE), 
           IDMTY.DM_ApplColumn('SIBLINGS', NULL, B.SIBLINGS), 
           IDMTY.DM_ApplColumn('INCOME', NULL, B.INCOME))) 
  FROM BANKING_SCORING B, ClusterModels C WHERE C.MODELNAME = 'DemoBanking'; 
SELECT IDMMX.DM_getClusterID( CLUSTER_RESULT ) ClusterID, 
       IDMMX.DM_getClusScore( CLUSTER_RESULT ) ClusterScore
FROM CLUSTERVIEW;

Quick start using the sample applications

The aim of this chapter is to get you up and running quickly in using the IM Scoring samples. It provides information on the tasks that you need to complete to get started. Refer to DB2 Intelligent Miner Modeling, DB2 Intelligent Miner Scoring, DB2 Intelligent Miner Visualization: Installing the Intelligent Miner products for a detailed description on how to install and configure IM Scoring.

Refer to Sample files and Completing the practice exercises to find samples and to become more familiar with the IM Scoring mining functions. These sections guide you through a tutorial of practice exercises on sample data. By using the data and scripts provided with the IM Scoring package and the instructions given in these sections, you become familiar, for example, with the following actions:

All the tasks in the practice exercises are completed by means of sample scripts. The scripts include standard SQL commands, such as INSERT, and scoring functions, such as DM_impClusFile. The contents of the scripts are given in these sections so that you can see how the SQL statements are structured. You can use these sample scripts as a basis for your own scripts.

IM Scoring provides a set of samples to help you to get familiar with the UDFs and UDTs.

Creating database objects

The UDTs and UDFs (refer to Scoring data types and functions) provided with IM Scoring must be created in the databases that you want to use with IM Scoring. To enable the default Oracle database, run the script idm_setup, which is available in the bin directory of your IM Scoring installation. The script calls SQL*Plus and runs several other SQL scripts that create the necessary database objects. You can enable another database by switching the default database. To do this, change the environment variable ORACLE_SID as necessary, and run idm_setup again.

For more information refer to The idm_setup command.

Generating SQL scripts from your own mining models

If you already have PMML models, you can generate SQL scripts from them by using the idmmkSQL tool. These scripts will contain template SQL statements that import and apply the model. The SQL script contains placeholders that you replace with the names of concrete database objects in order to finally get the executable SQL script.

For more information, see:

You can find a practice exercise in using the idmmkSQL tool at Using idmmkSQL to work with your own mining models.

Sample files

The IM Scoring package includes sample files consisting of a series of practice exercises in using IM Scoring. This tutorial material enables you to:

The IM Scoring sample files reside in the samples/ScoringOracle directory of your IM Scoring installation. This directory contains the mining model, data, and scripts that you require to complete the exercises in this chapter.

On Windows(R) you can also use the shortcut IBM DB2 -> Business Intelligence Tools -> Intelligent Miner Scoring 8.2 -> Samples - Oracle in the program folder. This displays a short help topic about how to run the samples.

The IM Scoring Java Beans examples are available in samples/ScoringBean.

Table 4 and Table 5 list the files that are included in the samples directory and explain the purpose of each.

Table 4. Sample files for the Clustering mining function of IM Scoring
Sample file Description
readme.txt A README file containing instructions on how to use the sample files.
idm_create_demotab.sql A script that creates three tables, which are used to store models and their names.
idm_drop_demotab.sql A script that drops the tables created by idm_create_demotab.sql.
banking_import.sql A script that creates the sample table banking_scoring, and calls banking_populate.sql to write the data to the table banking_scoring.
banking_populate.sql A script containing a sequence of INSERT statements that write the records of a bank's customers to the table banking_scoring. This is the data to which you will apply the model.
clusDemoBanking.pmml A Distribution-based Clustering model in PMML format. The model was built from data for a bank's customers who have a particular type of account. Customers are grouped according to similarities of age, income, number of siblings, gender, and account type.
clusNeuralBanking.pmml An exported Center-based Clustering model. The model was built from data for a bank's customers.
banking_insert.sql A script that imports the model, which is stored in the file clusDemoBanking.pmml, and then inserts the model into the table CLUSTERMODELS.
banking_extract.sql A script that extracts various information from the model that has been imported into the database by means of the script banking_insert.sql.
banking_apply1.sql

A script that applies the imported Clustering model to the specified data from the table banking_scoring, and then obtains values from the calculated results. The script uses DM_ApplRow and DM_ApplColumn to construct data of the type DM_ApplicationData.

banking_apply2.sql A script that applies the imported Clustering model to the specified data from the table banking_scoring, creates a results table, stores the calculated results in the table, and then obtains results values from the table. The script uses DM_ApplRow and DM_ApplColumn to build the input data records.
banking_apply3.sql Like banking_apply2.sql, except that it uses the DM_applData function instead of DM_ApplRow and DM_ApplColumn to construct data of the type DM_ApplicationData.
banking_apply4.sql Like banking_apply2.sql, except that it uses the CONCAT function instead of DM_ApplRow and DM_ApplColumn to construct data of the type DM_ApplicationData.
compressV7Models.sql The script compresses models that have been created with IM Scoring V 7.1. For more information refer to Migrating from IM Scoring V7.1 and Migrating from IM Scoring Version 8.1.
PredictFunctions-readme.txt A README file explaining the additional prediction UDFs.
PredictFunctions-sample.sql A script that provides a sample how to use the clustering prediction functions.
Table 5. Sample files for IM Scoring Java Beans
Sample file Description
SampleDemoBanking_Oracle.java A sample program that applies a model in an Oracle database using the Java Single Record Scorer.
93er_cars.pmml A Polynomial Regression model
Sample93erCars.java A sample Java program
readme.txt A README file

Completing the practice exercises

Before you can complete the practice exercises, you must install IM Scoring and configure the system environment as described in DB2 Intelligent Miner Modeling, DB2 Intelligent Miner Scoring, DB2 Intelligent Miner Visualization: Installing the Intelligent Miner products.

The tutorial introduces the following tasks:

Notes:
  1. Before starting the tasks, choose an Oracle user account for whom you want to create the tables and run the scoring functions. Then call SQL*Plus and log in to this account.
  2. Before you call SQL*Plus, you might want to open a command window and change to the samples directory. For information about the samples directory, see Sample files. If you call SQL*Plus from this directory, you do not need to repeatedly enter the entire path to access the sample scripts. Call SQL*Plus by entering sqlplus. On Windows, you might prefer the GUI version sqlplusw.

Creating a table and importing data

In this exercise, you create a table and import the banking data. You will later apply the mining model to this data.

To create a table and import the sample data, which is contained in the file banking_populate.sql, run the sample script banking_import.sql by using the following SQL*Plus command:

@banking_import

In the first part of the script banking_import.sql, the table banking_scoring is dropped. The PL/SQL code avoids an error message if the table does not exist. The second part recreates the table and defines the columns and their data types. At the end, the script calls another script banking_populate.sql, which inserts some records into the table banking_scoring:

 
BEGIN
  EXECUTE IMMEDIATE 'DROP TABLE BANKING_SCORING';
EXCEPTION
  WHEN OTHERS THEN
    NULL;
END;
/

CREATE TABLE BANKING_SCORING (
   TYPE            CHAR(7),
   GENDER          CHAR(6),
   AGE             NUMBER,
   PRODUCT         CHAR(1),
   SIBLINGS        NUMBER,
   INCOME          NUMBER
  );

@@banking_populate.sql
 

Creating sample tables for mining models and importing a model

In this exercise, you create the tables that are used to store mining models, and you import a sample mining model into one of these tables.

To create the sample tables for mining models, use the following command in SQL*Plus to run the script idm_create_demotab.sql:

@idm_create_demotab

The script creates three tables in your schema:

Each table has a column for storing the model name, and a column for storing the model itself.

Keep in mind that you can drop these tables with script idm_drop_demotab.sql if the tables are no longer needed.

To import the sample mining model, which is stored in the file clusDemoBanking.pmml, use the following command to run the sample script banking_insert.sql:

@banking_insert

The following script shows an example for AIX(R). It uses the function DM_impClusFile, which is specific to IM Scoring, to import the mining model contained in the file clusDemoBanking.pmml. The SQL INSERT command inserts the mining model into a column in the table CLUSTERMODELS, and sets the name of the model to DemoBanking. The table CLUSTERMODELS is configured for the data type DM_ClusteringModel.

insert into CLUSTERMODELS values
  ( 'DemoBanking', IDMMX.DM_impClusFile
  ( '/usr/opt/IMinerX/V8.2/samples/ScoringOracle/clusDemoBanking.pmml'));
 commit; 
Note:
The absolute path of the PMML model is different on each platform. On Windows, the absolute path is automatically modified at installation time to be consistent with the chosen installation path.

Applying a model and getting results values

You can use different scripts to apply mining models and obtain the results of applying the mining model.

Getting the values of the calculated results

In this exercise, you apply the Distribution-based Clustering model to the banking data and get the values of the calculated results.

To apply the sample mining model and obtain the results of applying the model, use the following command to run the script banking_apply1.sql:

@banking_apply1

The sample script banking_apply1.sql contains the following statements:

execute IDMMX.DM_initialize

CREATE OR REPLACE VIEW CLUSTERVIEW (CLUSTER_RESULT) AS  
  SELECT IDMMX.DM_applyClusModel(C.MODEL,
           IDMTY.DM_ApplRow( 
             IDMTY.DM_ApplColumn('TYPE', B.TYPE, NULL),
             IDMTY.DM_ApplColumn('AGE', NULL, B.AGE), 
             IDMTY.DM_ApplColumn('SIBLINGS', NULL, B.SIBLINGS),
             IDMTY.DM_ApplColumn('INCOME', NULL, B.INCOME)))
   FROM BANKING_SCORING B, ClusterModels C WHERE C.MODELNAME = 'DemoBanking';
SELECT IDMMX.DM_getClusterID( CLUSTER_RESULT ) ClusterID,       
       IDMMX.DM_getClusScore( CLUSTER_RESULT ) ClusterScore
FROM CLUSTERVIEW;
DROP VIEW CLUSTERVIEW;

The script first calls the DM_initialize function, which must be called once per schema before you can use any of the apply scoring functions. Therefore, if you use another Oracle user account for executing scoring functions, first call DM_initialize to prepare the schema for executing application functions. You can call this function repeatedly if you are not sure whether you have already called it.

The script creates a view that defines a CLUSTER_RESULT column that is the result of applying the model DemoBanking to records of the table banking_scoring. Because DemoBanking is a Clustering model, the scoring function DM_applyClusModel is used. The data values are obtained using the user-defined types DM_ApplRow and DM_ApplColumn.

Next, the script obtains the cluster ID and the Clustering quality from (CLUSTER_RESULT) by using the functions DM_getClusterID and DM_getClusScore. The SELECT statement writes these two final results to the screen. Finally, the view is dropped because it is no longer used.

Storing scoring results permanently

To apply the sample mining model, store results, and obtain results values, run the script banking_apply2.sql by using the following command:

@banking_apply2

The following sample script shows part of the content of banking_apply2.sql:

execute IDMMX.DM_initialize 

CREATE TABLE BANKING_APPLY(
   TYPE            CHAR(7),
   GENDER          CHAR(6),
   AGE             NUMBER,
   PRODUCT         CHAR(1),
   SIBLINGS        NUMBER,
   INCOME          NUMBER,
   CLUSTER_RESULT  VARCHAR2(512)
);
 
INSERT INTO BANKING_APPLY
  SELECT B.TYPE, B.GENDER, B.AGE, B.PRODUCT, B.SIBLINGS, B.INCOME,
         IDMMX.DM_applyClusModel(C.MODEL,
           IDMTY.DM_ApplRow(
             IDMTY.DM_ApplColumn('TYPE', B.TYPE, NULL),
             IDMTY.DM_ApplColumn('AGE', NULL, B.AGE),
             IDMTY.DM_ApplColumn('SIBLINGS', NULL, B.SIBLINGS),
             IDMTY.DM_ApplColumn('INCOME', NULL, B.INCOME)))
    FROM BANKING_SCORING B, CLUSTERMODELS C WHERE 
    C.MODELNAME = 'DemoBanking';
 
SELECT AGE, IDMMX.DM_getClusterID( CLUSTER_RESULT ) ClusterID,
            IDMMX.DM_getClusScore( CLUSTER_RESULT ) ClusterScore
FROM BANKING_APPLY WHERE AGE > 50;
 
DROP TABLE BANKING_APPLY;

First, the script calls DM_initialize; note that this is necessary only if it is not already done. The script creates a table for the mining results by defining the names and the data types of the table columns. The last column, CLUSTER_RESULT, is designated for the calculated results. This column has a data type of VARCHAR2, which is the source data type for DM_ClusResult. DM_ClusResult is the data type returned by DM_applyClusModel. The script then applies the DemoBanking model to selected data from the banking_scoring table by using function DM_applyClusModel. Next, it obtains the cluster ID and the Clustering quality from the CLUSTER_RESULT column of the new table by using the functions DM_getClusterID and DM_getClusScore. Finally, it drops the table BANKING_APPLY.

You can also apply models and compute cluster IDs in a single SQL query. The following example shows an SQL query of this kind:

  
SELECT B.TYPE, B.GENDER, B.AGE, B.PRODUCT, B.SIBLINGS, B.INCOME,
       IDMMX.DM_getClusterID(     
         IDMMX.DM_applyClusModel(C.MODEL,
            IDMTY.DM_ApplRow(
              IDMTY.DM_ApplColumn('TYPE', B.TYPE, NULL),
              IDMTY.DM_ApplColumn('AGE', NULL, B.AGE),
              IDMTY.DM_ApplColumn('SIBLINGS', NULL, B.SIBLINGS),
              IDMTY.DM_ApplColumn('INCOME', NULL, B.INCOME)))) AS ClusterID
  FROM BANKING_SCORING B, CLUSTERMODELS C WHERE C.MODELNAME = 'DemoBanking';
 
Tip:
In the script banking_apply1.sql, you calculate the cluster ID and cluster score based on the column CLUSTER_RESULT of the view clusterView. In the script banking_apply2.sql, you calculate the cluster ID and cluster score based on the column CLUSTER_RESULT of a table. In the first case, the calculation of CLUSTER_RESULT in the final SELECT statement might be performed more than once. Oracle might calculate it for the DM_getClusterID function and for the DM_getClusScore function. In the second case, the calculation is performed just once because the result is stored in a temporary table. Choose the second approach if you want to get better performance.

Extracting information from a model

In this exercise, you extract information from a model.

The model from which you extract information is the one that you inserted into the database as part of the exercise in the section Creating sample tables for mining models and importing a model.

The information that you extract is:

To extract the information, run the script banking_extract.sql by using the following command:

@banking_extract

The sample script banking_extract.sql contains the following statements:

 
COLUMN CLUSTERMODELNAME FORMAT A60 
COLUMN NO_OF_CLUSTERS FORMAT 9999 
COLUMN FIELDNAME1 FORMAT A15 
COLUMN FIELDNAME2 FORMAT A15 
COLUMN FIELDNAME3 FORMAT A15 
COLUMN FIELDNAME4 FORMAT A15


CREATE OR REPLACE VIEW MODELCONTENT ( CLUSTERMODELNAME, NO_OF_CLUSTERS,
 MODELFIELDS ) AS
   SELECT IDMMX.DM_getClusMdlName( MODEL ),
          IDMMX.DM_getNumClusters( MODEL ),
          IDMMX.DM_getClusMdlSpec( MODEL )
   FROM CLUSTERMODELS WHERE MODELNAME = 'DemoBanking';


SELECT CLUSTERMODELNAME, NO_OF_CLUSTERS,
       IDMMX.DM_getFldName(MODELFIELDS, 1) AS FIELDNAME1,
       IDMMX.DM_getFldName(MODELFIELDS, 2) AS FIELDNAME2,
       IDMMX.DM_getFldName(MODELFIELDS, 3) AS FIELDNAME3,
       IDMMX.DM_getFldName(MODELFIELDS, 4) AS FIELDNAME4
FROM MODELCONTENT;
 

Using IM Scoring Java Beans to score records

In this exercise, you use IM Scoring Java Beans to score records. To do this, you use the sample program Sample93erCars.java, which you can find in the IM Scoring installation directory under samples/ScoringBean.

In the example, the minimum price of a car is predicted, given the basic characteristics for a car. The data used to train and generate the mining model contained a large number of fields, including:

The training data also contained the actual Minimum Price (in $1000), which was used as the predicted field when the mining model was generated. When IM Scoring Java Beans is used with this model, the scorer predicts the minimum car price for new, previously unseen data.

First, IM Scoring Java Beans is set up to be used for scoring runs. The section of code that follows shows the source code that is used to do this. Here, a constructor is provided that takes as its input parameter the name of the file in which the mining model is stored.

In the example, the model file 93er_cars.pmml is located in the same directory as the sample program. The constructor calls the method initModel(String modelFile), where the instance variable scorer is initialized with the new mining model. This initialization can be done by means of the constructor of the RecordScorer class, or by using the openModel(String modelFile) method.

This operation can take some time, because the mining model is loaded into memory, parsed, and interpreted for scoring. When this is complete, the initialized scorer is prepared for scoring.

Source code: Setting up the RecordScorer

public Sample93erCars(String modelFile ) {
        initModel( modelFile ); 
    }


    public void initModel( String modelFile ) {
        try {
            // set the new model file and load the model as preparation for 
            // following scoring runs
            if ( scorer == null ) {
                scorer = new RecordScorer( modelFile ); 
            } else scorer.openModel( modelFile ); 
        } catch ( ModelException e ) {
            e.printStackTrace(); 
        }
    }

When the setup of RecordScorer is complete, it can be used immediately for scoring on a record-by-record basis and for the reading of results. The source code given in Source code: Applying scoring on a record-by-record basis shows how this works.

The record that you want to score is the input for the doScoring(Map record) method. The call to scorer.score(record) computes the scoring result. The result is stored as an instance variable in the scorer object, and can be accessed now by means of the getPredictedValue() method. To keep the scoring API as simple and small as possible, there are no extra result objects provided for each of the model types. Instead, the RecordScorer provides a set of methods that are used to access the computed result fields. If a method is called that does not suit the actual model type, a ResultException is thrown. A call to getClusterID(), for example, instead of to getPredictedValue() in the code given in Source code: Applying scoring on a record-by-record basis would result in such an exception.

Source code: Applying scoring on a record-by-record basis

 /**
    * Applies scoring: Gets a record as input, applies scoring
    * and displays the output.
    * @param record the record used for scoring
    */
   public void doScoring( Map record ) {
  
     if ( scorer != null ) {
         try {
            // do scoring now
            scorer.score( record );

           // Before reading the results, validate that the
           // model type is set to regression.
            if ( scorer.getModelType() == Scorer.REGRESSION_TYPE ) {
                double predictedValue = scorer.getPredictedValue();
                displayPredictionResult( record, predictedValue,
                  "minimum car price" );
            }
  
         } catch ( Exception e ) {
             // an error occurred while scoring the record
             e.printStackTrace();
         }
     }
  }

The code given in Source code: Accessing model metadata shows how access is gained to the metadata of the mining model that is used. For a specified model, it is possible to retrieve the active mining fields that are used, as well as the mining types of these fields. A field that is used by the mining model for the computation of the scoring result is known as an active mining field. In the method displayActiveFields(), the active fields and their related mining types are displayed.

Source code: Accessing model metadata

 /**
  * Displays the active fields of the mining model that was used.
  * The active fields are the ones that are used by the mining
  * model for scoring.
  */
 public void displayActiveFields() {
    if ( scorer != null ) {
        String[] activeFields = scorer.getFieldNames();
        if ( activeFields != null ) {
            System.out.println( "\nActive Fields: " );
             for ( int i=0; i<activeFields.length; i++ ) {
                System.out.print( "Field Name: " + activeFields[i] );
                if ( scorer.isCategoricalField( activeFields[i] ) ) {
                  System.out.println( ", Mining Type: categorical" );
                } else {
                    System.out.println( ", Mining Type: numerical" );
                }
            }
        }
    }
 }

The code given here in Source code: The main program shows the main program. Here, the following scenario is demonstrated:

Source code: The main program

 public static void main( String[] args ) {
  
   File file = new File( "93er_cars.pmml" );
   Sample93erCars obj = new Sample93erCars( file.getAbsolutePath() );
  
 HashMap record = new HashMap();

    // A customer starts with the specification of some basic features
    // that the car should have. The engine should be powerful, with
    // 200 horsepower. The car should have good safety features,
    // so that 2 airbags should be available.
    // As well, it should use only a moderate amount of gas when
    // being driven in the city.
    // The estimated minimum price is predicted.
    record.put( "Horsepower", new Integer(200) );
    record.put( "Air Bags standard", new Integer(2) );
    record.put( "City MPG", new Integer(17) );
    carPricePredictor.doScoring( record );
  
    // After hearing the estimated price, the customer gets more
    // specific, and asks for some more features.
    // The car should not be longer than 185 inches, and should be
    // at least 68 inches wide.
    record.put( "Width (inches)", new Integer(68) );
    record.put( "Length (inches)", new Integer(185) );
    carPricePredictor.doScoring( record );

    // The customer now details the requirements for the engine and the
    // driving behavior, and wants to know the new estimated price.
    record.put( "Number of cylinders", new Integer(8) );
    record.put( "RPM", new Integer(5500) );
    record.put( "U-turn space (feet)", new Integer(40) );
    carPricePredictor.doScoring( record );

    // Finally, the customer adds some details about how the inside of
    // the car should look.
    // Note: If you look at the model 93er_cars.pmml, you will see that
    // "Passenger capacity" and "Luggage capacity (cu.feet)" do not
    // appear at all. This means that these features do not affect
    // the predicted price. Even if the model does not contain these
    // fields, they can be specified in the record.
    record.put( "Rear seat room (inches)", new Integer(28) );
    record.put( "Passenger capacity", new Integer(28) );
    record.put( "Luggage capacity (cu. feet)", new Integer(30) );
    carPricePredictor.doScoring( record );
    }

To compile the Java program Sample93erCars.java:

  1. Set the PATH and CLASSPATH variables as described in Setting environment variables.
  2. Change to the sample directory.
  3. Type javac Sample93erCars.java

    This will generate the class file Sample93erCars.class.

To start the program, type java Sample93erCars.

The code given here in Results output for Sample93erCars shows the output of the program. The output demonstrates how the price varies with the new features that the car should have.

Results output for Sample93erCars:

 Active Fields:
 Field Name: Width (inches), Mining Type: numerical
 Field Name: U-turn space (feet), Mining Type: numerical
 Field Name: City MPG, Mining Type: numerical
 Field Name: Air Bags standard, Mining Type: numerical
 Field Name: Rear seat room (inches), Mining Type: numerical
 Field Name: Horsepower, Mining Type: numerical
 Field Name: RPM, Mining Type: numerical
 Field Name: Number of cylinders, Mining Type: numerical
 Field Name: Length (inches), Mining Type: numerical
  
 Prediction result:
 Horsepower: 200
 City MPG: 17
 Air Bags standard: 2
 =========================================
 Minimum Car Price (in $1000): 30.45425764285364
  
 Prediction result:
 Length (inches): 185
 Horsepower: 200
 Width (inches): 68
 City MPG: 17
 Air Bags standard: 2
 =========================================
 Minimum Car Price (in $1000): 32.57913872719416
  
 Prediction result:
 Number of cylinders: 8
 Length (inches): 185
 U-turn space (feet): 40
 Horsepower: 200
 RPM: 5500
 Width (inches): 68
 City MPG: 17
 Air Bags standard: 2
 =========================================
 Minimum Car Price (in $1000): 36.47348105441428
  
 Prediction result:
 Width (inches): 68
 U-turn space (feet): 40
 City MPG: 17
 Passenger capacity: 28
 Air Bags standard: 2
 Rear seat room (inches): 28
 Horsepower: 200
 RPM: 5500
 Number of cylinders: 8
 Luggage capacity (cu. feet): 30
 Length (inches): 185
 =========================================
 Minimum Car Price (in $1000): 36.41880910964151

Using idmmkSQL to work with your own mining models

In this exercise, you generate a template SQL script using the command line tool idmmkSQL. You then edit the template SQL script to create the final script and execute it.

To do this exercise, you must first have successfully completed the steps described in Creating a table and importing data.

To generate a template SQL script that contains the necessary SQL statements to perform a scoring run:

  1. Execute the following command:
    idmmkSQL -d Oracle clusDemoBanking.pmml clusDemoBanking.sql
    This generates the file clusDemoBanking.sql.
  2. Open the file clusDemoBanking.sql with an editor of your choice and perform the following modifications:
    Note:
    idmmkSQL uses default tables to store mining models. If different tables are used, the following modifications are required in addition to this:
    • Replace IDMMX.CLUSTERMODELS with the name of the table which is determined to store mining models. This appears twice in the file.
    • Replace MODEL with the column name containing the mining model name.
    • Replace MODELNAME with the column name containing the mining model.
  3. Save the modified file.

To run the script clusDemoBanking.sql, use the following command in SQL*Plus:

@clusDemoBanking.sql

The script:

  1. Imports the PMML model clusDemoBanking.pmml into the table CLUSTERMODELS
  2. Performs a scoring run with the input data from the table BANKING_SCORING
  3. Writes the results into the table RESULTTABLE

You can display the results using the following SQL statement:

SELECT * FROM RESULTTABLE

The results are the same as with the scripts banking_apply1.sql, which you executed in a previous exercise.

Using IM Scoring

This chapter guides you through the use of IM Scoring to perform data mining tasks within a database. Use IM Scoring to:

Scoring data types and functions

The database objects supplied with IM Scoring consist of the following:

The UDTs and the UDFs are grouped together in the package IDMMX. The UDTs are either defined in the package IDMMX or in the schema IDMTY. Note that the package does not export the UDTs. You must use the source data types (described in Data types reference) when you create tables with UDTs. To access a UDF, you must specify the fully qualified name, for example, IDMMX.DM_applyClusModel.

The data types and functions are designed along the proposed SQL Standard ISO/IEC 13249-6 SQL/MM Part 6: Data Mining.

Reference supplies overview lists and full descriptions of all the database objects supplied with IM Scoring.

User-defined data types

The user-defined data types are used for identifying and storing mining models and results in Oracle tables and for constructing input data for the scoring functions. User-defined data types are also referred to as user-defined types or UDTs.

The user-defined data types provided by IM Scoring consist of distinct types and object types. However, the distinct types are used internally in the package IDMMX and are not visible to the user. Therefore, the "real" parameter types of the UDFs are the source data types of the distinct types. Nevertheless, distinct types are used in the definition of the UDFs in this book in order to better express the meaning of these types.

Distinct types
The following user-defined types are distinct types in IM Scoring:
Object type
The following user-defined types are object types in IM Scoring:

User-defined functions

IM Scoring provides scoring functions, also referred to as user-defined functions (UDFs), which enable you to:

Creating database objects

Enabling databases

IM Scoring provides a set of new UDTs and UDFs. Before you can use them from SQL statements, they must be created in the database as database objects. In other words, the database must be enabled for the use of IM Scoring.

To enable an Oracle database for IM Scoring, call the command idm_setup. It can be found in the bin directory of your IM Scoring installation.

The program asks for the password of the predefined Oracle user SYS. It calls SQL*Plus and executes a number of SQL scripts that create the necessary database objects. The output from the object creation commands is displayed and written to the file setup.log. Check this log file for any errors. Enter exit on the command line to leave SQL*Plus.

The setup scripts create an Oracle data cartridge in the default database that contains all the scoring functions and some data types. The scoring functions are implemented in a package that is accessible to all users through the public synonym IDMMX. In addition, the scripts create a new user and the schema IDMTY, which also stores some data types.

You must call the command idm_setup for each database that you want to use with IM Scoring. To make this possible, change your default database (by means of the environment variable ORACLE_SID) and call idm_setup again.

For complete instructions on using this command, see The idm_setup command.

Disabling databases

To disable databases, IM Scoring provides the SQL script idm_uninstall. This script drops from the default database all the IM Scoring UDTs, UDFs, and schemas that were created. Call this script if you no longer want to use a database with IM Scoring, or before you uninstall IM Scoring.

To execute the script:

  1. Go to the bin directory of your IM Scoring installation
  2. Call SQL*Plus, and connect to the database that you have enabled
  3. Log in as user SYS
  4. Enter @idm_uninstall to execute the script
  5. Type exit to leave SQL*Plus

The script idm_uninstall must be executed for each database that you want to disable. To make this possible, change your default database (by means of the environment variable ORACLE_SID) and call idm_uninstall again.

Note that idm_uninstall drops database objects without checking if there are dependencies on other objects. Therefore, database objects that are dependent on one of IM Scoring's new types or functions might become invalid.

For instructions on using this command, see The idm_uninstall command.

Deploying mining models

This section shows how to obtain mining models to be scored in IM Scoring. Introducing IM Scoring familiarizes you with the tools for creating mining models. It also introduces you to the different model formats that can be used.

Exporting models from IM for Data

IM for Data stores models as results objects within an internal structure, and allows you to export these objects to an external file.

To export a results object, follow these steps:

  1. Click the results object on the IM for Data GUI.
  2. From the Selected menu, click Export.
  3. Select one of the following formats:

If you export a model in PMML or XML format, an XML encoding is written into the file. The XML encoding is determined by the language environment and the locale of the IM for Data client V8.1.

For more information refer to Appendix D. Using IM Scoring in a multilanguage environment.

Converting exported models

You can convert mining models in Intelligent Miner format to PMML 2.1 format by using the command line tool idmxmod. The input model in Intelligent Miner format must exist as a flat file. The output model in PMML format is also contained in a flat file.

For instructions on using this command line tool, see The idmxmod command.

Importing mining models

The IM Scoring functions for importing mining models read a file that contains the mining model or a CLOB value from a database table that contains a PMML model. Each import function returns the mining model as data of one of the data types specific to IM Scoring.

You can use an SQL command to insert the returned data into a table where a column has been configured for the appropriate data type.

The IM Scoring package contains sample tables that are configured for the imported models. The sample tables can be created by running script idm_create_demotab.sql. See also Creating sample tables for mining models and importing a model.

Errors can occur in the following circumstances:

Importing mining models from a file

The import functions import a mining model from a file and return it as a value of the appropriate data type. Table 6 shows the relationship between the import function, the returned data type, and the sample table. For XML files, the XML encoding specification in the XML header is respected. If the encoding specification does not exist, UTF8 is assumed. For more information on encoding, see Appendix D. Using IM Scoring in a multilanguage environment.

Table 6. Import functions and related data types and tables
Import function Data type Table
DM_impClusFile DM_ClusteringModel CLUSTERMODELS
DM_impClasFile DM_ClasModel CLASSIFMODELS
DM_impRegFile DM_RegressionModel REGRESSIONMODELS

Figure 4 illustrates the relationship between model type, scoring functions, and the data type of the column in the Oracle table.

Figure 4. Model import processes
Model import processes overview

You can use the following SQL command to import the file myclusters.xml and insert it into the CLUSTERMODELS table in your schema:

Note:
The absolute path to the model file must be given.
insert into CLUSTERMODELS 
values ('CustomerSegments', IDMMX.DM_impClusFile('c:\tmp\myclusters.xml'))

Importing mining models from a file using a specific XML encoding

With IM Scoring's import functions, you can override the encoding specification given in the XML file and explicitly specify the encoding to be assumed for the file to be imported.

The import functions of IM Scoring listed in Table 7 use a specific XML encoding to import a mining model from a file and return it as a value of the appropriate data type.

Specifying an XML encoding can be required, for example, if the encoding specified in the file is an unsupported name for a supported code page, or if the encoding of the file has been changed without changing the encoding written in the file.

Table 7 shows the relationship between the import function, the returned data type, and the sample table. The encoding of characters in the imported file is given explicitly. For more information on encodings, see Appendix D. Using IM Scoring in a multilanguage environment.

Table 7. Import functions using a specific XML encoding
Import function Data type Table
DM_impClusFileE DM_ClusteringModel CLUSTERMODELS
DM_impClasFileE DM_ClasModel CLASSIFMODELS
DM_impRegFileE DM_RegressionModel REGRESSIONMODELS

You can use the following SQL command to import the file myclusters.xml and insert it into the CLUSTERMODELS table in your schema:

 insert into CLUSTERMODELS values( 'CustomerSegments',
            IDMMX.DM_impClusFileE('c:\tmp\myclusters.xml', 'iso-8859-1' )

Importing mining models from a CLOB value in a database table

You can use import functions that import a PMML model that already resides in a database table column as a CLOB value.

Table 8 shows the relationship between the import function, the returned data type, and the sample table.

Table 8. Import functions using CLOB values
Import function Data type Table
DM_impClusModel DM_ClusteringModel CLUSTERMODELS
DM_impClasModel DM_ClasModel CLASSIFMODELS
DM_impRegModel DM_RegressionModel REGRESSIONMODELS

The following is an example of the use of these import functions.

  1. A model name and a model in PMML format as a CLOB value are selected from a table, PMMLCLUSTERMODELS.
  2. They are then inserted into the CLUSTERMODELS table.
  3. The PMML model is converted from the CLOB data type to the DM_ClusteringModel data type.
  insert into CLUSTERMODELS select modelname,
  IDMMX.DM_impClusModel( model ) from PMMLCLUSTERMODELS
 

Generating SQL statements from models

It can be time consuming to manually write the SQL scripts that contain the necessary SQL statements for applying a model to a set of input records. This is especially the case if there are a lot of mining fields. For this reason, IM Scoring provides a separate tool, the idmmkSQL command, that generates from mining models the SQL statements that you need. The tool:

  1. Analyzes an input file containing a PMML model
  2. Writes a template SQL script that can be used to do these tasks:

The template script contains placeholders for actual values like table names or file names. You have to manually insert these values into the template to get the final SQL script.

The idmmkSQL command supports the different ways of building input data records for the application functions that are provided by IM Scoring. The tool has a command line interface. The type of SQL and the method of building input data records can be controlled by command line parameters.

For instructions on using this tool, see The idmmkSQL command.

Extracting information from a model

You can extract, for example, the following information from a model in the database:

To extract the information, you define a script and then run the script. An example of how to extract information is provided in Extracting information from a model.

Applying mining models

This section contains instructions on applying mining models. It is important to get the best possible result when you apply a model to new data records. To ensure this, provide a value in a data record for each active field in the model. The data record consists of a set of field names and their values. The field names in the set match the names of the active fields in the model.

If necessary, you can access information about the active fields in your model. For a sample script that does this, see Extracting information from a model.

Using the application functions

IM Scoring includes functions that apply imported mining models to selected data. Table 9 lists each function together with a brief summary of how it is used.

Table 9. Functions for applying models
Application function Purpose
DM_applyClusModel Applies a model to selected data to produce results data, grouped into clusters. Clusters are identified when the model is built. They identify similar characteristics in data.

A possible use of this function is in producing targeted mailshots.

DM_applyClasModel Applies a model to selected data to produce results data that is classified according to rules established when the model is built.

A possible use of this function is in classifying insurance risks.

DM_applyRegModel Applies a model to selected data to calculate a predicted value. The predicted value is based on the values of input fields, according to a pattern established when the model is built.

A possible use of this function is in ranking customers.

Each function has the following input arguments:

An imported mining model of the appropriate type
The mining models are assumed to reside in a table. One column of the table contains the identifier or the name of the model. The other column contains the model itself. In this case, the WHERE clause in the SELECT statement determines which model is the input to the application function. You can use as many models in the same SQL statement as there are entries in the model cache. That means that you can use up to two models within one and the same SQL statement. Typically, you write the WHERE clause so that only one model is selected. However, it is also possible, for example, to apply two models to an input record in the same SELECT statement. Another example is the comparison of the results of two different versions of a model in the WHERE clause of a SELECT statement.
The data to which the model is applied
You can use the function DM_applData, DM_impApplData, or a constructor of DM_ApplRow to define the data to which you want to apply a model. These functions construct an instance of the data type DM_ApplicationData. To select several data items, you can choose one of the following options:
Note:
Use the function DM_applData, DM_impApplData, or a DM_ApplRow constructor to get a value of data type DM_ApplicationData. Do not use CHAR, VARCHAR2, or CLOB data directly where a value of data type DM_ApplicationData is needed.

The function returns results data that contains the values that the mining logic calculates.

The field names contained in the XML data record value are mapped to the fields in the applied model using the following logic:

  1. A field name is compared with the field names in the PMML model that are contained in the attribute displayName in the element DataField.
  2. If there is no match, a field name is compared with the field names in the PMML model that are contained in the name attributes in the DataField elements.

The field names in the displayName attribute and the name attribute might differ.

If you created the model by using IM for Data, the attribute displayName is empty, and the attribute name contains the name of the field used in IM for Data.

Specifying data by means of DM_ApplRow and DM_ApplColumn

The recommended way to construct the input data for the application functions is to use DM_ApplRow and DM_ApplColumn. This way is slightly slower than using CONCAT and slightly more expensive to write than DM_applData. However, it does not have the disadvantages of the other two methods. (For a description of these disadvantages, see the next two sections.) The UDTs IDMTY.DM_ApplRow and IDMTY.DM_ApplColumn enable you to construct the input for the application functions. These data types are defined as follows:

 
create type DM_ApplColumn as object (
  label     VARCHAR2(64),
  charValue VARCHAR2(128),
  numValue  NUMBER
);

create type DM_ApplRow as table of DM_ApplColumn;
 

DM_ApplColumn stores the label for a field that is defined in the model and its field value obtained from the current data record. If the value is of the 'character' data type, use charValue to store it. If it is of the 'number' data type, use numValue to store it. You must set either charValue or numValue to NULL to indicate that the other is valid. This way, DM_ApplColumn can store the equivalent information to the following:

DM_ApplRow is used to line up all DM_ApplColumn definitions for a data record.

The following is an example of the use of DM_ApplRow and DM_ApplColumn. It shows the create view statement that is part of the sample banking_apply1.sql.

CREATE OR REPLACE VIEW CLUSTERVIEW (CLUSTER_RESULT) AS  
  SELECT IDMMX.DM_applyClusModel(C.MODEL,
           IDMTY.DM_ApplRow(
           IDMTY.DM_ApplColumn('TYPE', B.TYPE, NULL),
           IDMTY.DM_ApplColumn('AGE', NULL, B.AGE),
           IDMTY.DM_ApplColumn('SIBLINGS', NULL, B.SIBLINGS), 
           IDMTY.DM_ApplColumn('INCOME', NULL, B.INCOME))) 
  FROM BANKING_SCORING B, ClusterModels C WHERE C.MODELNAME = 'DemoBanking';
Note:
It is still supported, but not recommended that you pass a DM_ApplRow object to the DM_impApplData function, and then use this function as a parameter for the application functions.

Specifying data by means of DM_applData

You can use the function DM_applData to construct the type DM_ApplicationData if the following is true:

The DM_ApplicationData value is the input for the application functions.

For each column of your input data table, there must be a call to DM_applData that processes the value of this column. This value and the corresponding field name in the model is passed to DM_applData, and DM_applData assembles an XML string out of that. DM_applData is called in a nested way, this causes the XML string to grow with each call, since DM_applData concatenates the XML strings generated with each call. Thus, the final result is an XML string that contains a sequence of field name/value pairs. The XML string is of type DM_ApplicationData and is used as the input for the various application functions.

Consider the following situation. You have an input table B that contains the columns Type and Age, and the mining fields in the model have these names as well. In this case, you can use DM_applData as follows:

 IDMMX.DM_applData(IDMMX.DM_applData('TYPE', B.TYPE), 'AGE', B.AGE)

The innermost call of DM_applData has only two parameters, field names and value. All the other calls have three parameters, because the result of a DM_applData call is input for the embracing DM_applData call.

For example, the following call corresponds to the call described in Specifying data by means of CONCAT:

IDMMX.DM_applData( IDMMX.DM_applData( 'CHARCOL', CHARCOL ) , 
'DOUBLECOL', DOUBLECOL )

Specifying data by means of CONCAT

For performance-critical applications use the built-in operator CONCAT, or the corresponding characters ||, in a sequence to construct the type DM_ApplicationData. For more information on the required format of the string, see DM_impApplData.

For example, the following calls correspond to the example described in Specifying data by means of DM_applData.

IDMMX.DM_impApplData('<row><column name="CHARCOL">'
||CHARCOL||'</column> '||'column name="DOUBLECOL">'
  ||DOUBLECOL||'</column></row>')

The concatenation operator implicitly converts a NUMBER argument to a VARCHAR2 string. The characters that are used for the conversion are chosen according to the current territory of the session. However, the function DM_impApplData needs a dot as the decimal character for numbers. Therefore, if your current territory setting defines another character as the decimal character, you should replace DOUBLECOL in the example above by:

 
TO_CHAR(DOUBLECOL, 'TM9', 'NLS_NUMERIC_CHARACTERS=''.,''')

If the columns CHARCOL and DOUBLECOL have NULL values, you must call CONCAT as follows:

 
IDMMX.DM_impApplData('<row><column name="CHARCOL"'
||NVL2(CHARCOL,'>'||CHARCOL,' null="true">')
||'</column>'||'<column name="DOUBLECOL"'
||NVL2(DOUBLECOL,'>'||DOUBLECOL,' null="true">')||'</column></row>')
Notes:
  1. IM for Data handles date values and time values in a character ISO format. You might want to specify a date value or a time value as CONCAT operator, and you might want to apply a model created by IM for Data. In this case, the date value and the time value must be converted to character ISO format. To do this, use TO_CHAR(<value>,'YYYY-MM-DD') for a date value and TO_CHAR(<value>,'HH24:MI:SS') for a time value.
  2. If you assemble your application data using CONCAT (or ||), you must use the SQL function NVL2 on columns that could contain NULL values. If a column has a character data type and you forget to use NVL2, you do not receive a warning, because a NULL value in a column of type CHAR or VARCHAR2 is treated as an empty string (which is a permitted value for categorical fields). In this case the apply function might calculate unexpected results.

Comparing DM_applData, CONCAT, and DM_ApplRow / DM_ApplColumn

You have three alternatives in constructing an instance of data type DM_ApplicationData:

Each alternative has its advantages and disadvantages:

Results data

The results data from each of the scoring functions is identified by a data type that is specific to IM Scoring. Table 10 lists the application functions together with their data types and results data.

Table 10. Application functions and their data types and results data
Application function Data type Results data
DM_applyClusModel DM_ClusResult Cluster ID, score, quality, confidence
DM_applyClasModel DM_ClasResult Predicted class, confidence
DM_applyRegModel DM_RegResult
  • Predicted value
  • Data region ID for an RBF Regression model
Note:
If you create your own Oracle tables to store results, ensure that you include a column that is configured for the appropriate data type.

Figure 5 illustrates the process by which data is selected and a model is applied. Values for the fields age and salary are read from a database table to form an instance of the data type DM_ApplicationData. This data and the model, ClusterModel, form the input to the function DM_applyClusModel. The results of applying the model consist of a cluster ID and a cluster score. The results are returned as data type DM_ClusResult.

Figure 5. Applying a model to data
Applying a model to data

Getting application results

IM Scoring includes results functions that obtain the different results values calculated within the application functions. This section lists and describes these functions. It also includes information about situations where input records contain NULL values; this is in Handling missing values.

Table 11 lists the results functions and describes the value that each function returns when a Clustering model is applied.

Table 11. Results functions and their purpose (Clustering model)
Results function Purpose
DM_getClusterID Obtains the cluster ID from results data calculated when a Clustering model is applied. This identifies the position of the cluster in the Clustering model that was the best match for this data record. The position of the cluster is a value between 1 and the number of clusters.
DM_getClusScore Obtains the score of the best cluster from results data calculated when a Clustering model is applied. The score is a measure of how closely the data matches the cluster.
DM_getQuality Returns the quality of the best cluster from results data calculated when a Clustering model is applied. The quality is a measure of how well the data fits into the cluster.
DM_getQuality(clusterid) Returns the quality for a specified cluster from results data calculated when a Clustering model is applied.
DM_getClusConf Returns the confidence of attributing a record to the best cluster in comparison with attributing it to another cluster of the applied model.

Table 12 lists the results functions and describes the value that each function returns when a Classification model is applied.

Table 12. Results functions and their purpose (Classification model)
Results function Purpose
DM_getPredClass Obtains the predicted class from results data calculated when a Classification model is applied. This identifies the class within the model to which the data matched.
DM_getConfidence Obtains the classification confidence value from results data calculated when a Classification model is applied. This is a value between 0.0 and 1.0; it measures the probability that the class is predicted correctly.

Table 13 lists the results functions and describes the value that each function returns when a Regression model is applied.

Table 13. Results functions and their purpose (Regression model)
Results function Purpose
DM_getPredValue Obtains the predicted value from results data calculated when a Regression model is applied. This value is calculated according to relations established by the model.
DM_getRBFRegionID Obtains the number of the region from results data calculated when an RBF Regression model is applied. This identifies the region within the model that the record was assigned to.

To obtain the results of applying a model, you run the appropriate results function, giving the return value of an application function as a parameter. This can be one of the following:

You pass the return value of the application function directly if you use only a single statement. That is, you apply the model and obtain the results value within a single statement. You use the database column name if the results of applying the model were stored in a table.

If you specify a column name, and the column is not configured for the correct results data type, an error occurs. See Table 10 for the relationships between results functions, results data types, and results data.

A results function might return a NULL value. This means that the application function that calculated the result could not determine this value, because the application function received a faulty data record as input. For example, the data record contained too many invalid values for a reasonable result to be returned.

Handling missing values

Input records might contain one or more values that are NULL; these are known as missing values. The handling of missing values in IM Scoring depends on the algorithm.

Notes:
  1. Fields defined in the PMML model can explicitly define a validity range. All values outside this range are considered as missing values.
  2. Fields defined in the PMML model can define a missing value replacement (PMML 2.0 and higher). In this case, all missing values are replaced by a valid value indicated in the model.
Classification
Clustering
Regression

Using the model cache for real-time scoring

IM Scoring provides a memory cache for mining models that improves the performance of scoring runs and allows real-time scoring. Real-time scoring ensures a fast response time for a scoring run of a single input record with an execution time that takes only a few milliseconds. Model caching allows to perform a scoring run in real time if:

Model caching allows to keep models in main memory for subsequent scoring runs. If there is no model cache, the model is deleted from the main memory after the scoring run (using the SELECT statement) has been finished. If a model is permanently stored in memory, a scoring run using this model is faster, because the initial loading and parsing phase can be skipped.

Since the model cache is realized inside the session-specific extproc agent process, there is one model cache for each database session. This agent remains active throughout your Oracle session. When you log off, extproc is terminated by Oracle, and consequently the cache is removed.

Each cache can store up to two models. A model is implicitly loaded into the cache with an apply function if it is not yet in the cache. If the cache is full, the new model automatically replaces an older model in the cache. Models can be removed from the cache at any time if a new model requires cache space.

Use the following stored procedures to control model caching:

execute IDMMX.DM_memoryFree
Removes all models from the cache. For more information refer to DM_memoryFree.
execute IDMMX.DM_printModelCache
Prints the names of the models in the cache. For more information refer to DM_printModelCache.

Performance considerations

A model cache can significantly improve the scoring speed of one or a few records against a model that is already in the cache. This is especially important for large models that need a lot of time for the open phase.

Note:
The more records are scored in one scoring run, the less is the relative performance improvement by using a cache.

The scoring run can be a bit slower than without cache:

Using IM Scoring Java Beans

This section describes the interfaces of IM Scoring Java Beans.

To perform the scoring of a data record, you must specify the following input:

  1. The mining model to be used
  2. One or more data records for which you want to compute a score value

When you have specified the necessary input, you can apply scoring and then access the result fields that have been computed.

The functions of IM Scoring Java Beans are implemented as methods of class com.ibm.iminer.scoring.RecordScorer.

Note:
You can access the online documentation (Javadoc) of the Java API using the following HTML start page in the IM Scoring installation directory:
\doc\ScoringBean\index.html

Setting environment variables

After you have installed IM Scoring Java Beans, you must set environment variables before you can use it from Java applications.

For a Java application to invoke RecordScorer, you must do the following:

For more information on how to set an environment variable refer to the documentation of your platform. For more information on IM Scoring Java Beans refer to the samples readme.

Specifying the mining model to be used

This section describes how to specify the model.

The RecordScorer class expects the mining model to be stored in one of the following:

Accessing model metadata

The RecordScorer class provides a set of functions that can be used to access the metadata of the mining model that is specified. These are as follows:

Table 14. IM Scoring Java Beans methods for accessing model metadata
Function Function description
public String[] getFieldNames() Returns the names of the mining fields used by the mining model to perform scoring. If no correct model is specified, a String[0] array is returned.
public String[] getCategoricalFields() Returns the names of the categorical mining fields used by the mining model to perform scoring. If no correct model is specified, a String[0] array is returned.
public String[] getNumericalFields() Returns the names of the numerical mining fields used by the mining model to perform scoring. If no correct model is specified, a String[0] array is returned.
public boolean
isCategoricalField(String fieldName)
Returns true if the field specified by fieldName is a categorical mining field. Otherwise, false is returned.
public boolean
isNumericalField(String fieldName)
Returns true if the field specified by fieldName is a numerical mining field. Otherwise, false is returned.
public boolean isField(fieldname) Returns true if the field specified by fieldName is one of the active mining fields. Otherwise, false is returned.
public int getModelType() Returns an integer value that identifies the type of the model that was used. For this, the constant CLUSTERING_TYPE, CLASSIFICATION_TYPE, REGRESSION_TYPE, and UNDEFINED_TYPE are defined in the Scorer class.
public int[] getResultIdentifiers() Returns the identifiers of the result fields that are relevant for the model type that is set. For this, there are additional constants defined in the class Scorer:
  • For CLUSTERING_TYPE, the result fields CLUSTER_ID, CLUSTER_SCORE, and CLUSTER_QUALITY are relevant.
  • For CLASSIFICATION_TYPE, the result fields PREDICTED_CLASS and CONFIDENCE are relevant.
  • For REGRESSION_TYPE, the result fields PREDICTED_VALUE and RBF_REGION_ID are relevant.

Specifying a data record

You can represent a data record by a mapping. Here, the names of the fields used in the records are mapped to their actual values. This is exactly the way in which a record is represented in the RecordScorer class. A java.util.Map object is instantiated, and a mapping between field names and values is defined. For example:

HashMap record = new HashMap(); 
record.put("Horsepower", new Integer(200) ); 
record.put("Air Bags standard", new Integer(2) ); 
record.put("City MPG", new Integer(17) ); 

Note that the values of categorical fields are interpreted as java.util.String, and the values of numerical fields are expected to inherit from java.lang.Number.

Using the Java Single Record Scorer

IM Scoring Java Beans can be used to score single or multiple data records using a specified mining model. IM Scoring Java Beans is designed to be used for applications where the online scoring of data records is the main task.

A possible application area of IM Scoring Java Beans might be the realization of an Internet-based call center scenario. In this scenario, the required business logic - in this case the scoring functions - runs on a Web or application server. Clients can connect to the server and send to it a data record that was specified by a call-center operator by means of a user interface on the client. The data record is scored on the server, and the result is passed back to the client in real time.

Figure 6 shows a simplified design, illustrating how such a scenario could be realized using IM Scoring Java Beans. Here, IM Scoring Java Beans is integrated into a J2EE implementation using, for example, servlets or Enterprise Java Beans.

Figure 6. Architecture sample to realize a call-center scenario
Architecture sample to realize a call-center scenario
Note:
To get optimum performance throughput, you might decide to run each mining model in a separate process. In this case, you would pass only the new records to the appropriate scoring process. This results in a considerable performance improvement. The reason for the improvement is that the model-loading step, which is very time consuming, is done only once.

For more information refer to Specifying the mining model to be used.

Applying scoring

After the mining model and a data record are specified, the score of the data record can be computed. For this purpose, the RecordScorer class provides the following method:

public void score( Map record ) throws RecordException, ModelException
 

Accessing computed results

After you have successfully called the score(Map) method, you can access the computed result fields by using one of the following methods:

Table 15. IM Scoring Java Beans methods for accessing computed results
Method Required model type Default value
double getClusterID() Clustering java.lang.Double.NaN
double getClusterScore() Clustering java.lang.Double.NaN
double getClusterQuality() Clustering java.lang.Double.NaN
String getPredictedClass() Classification NULL
double getConfidence() Classification java.lang.Double.NaN
double getPredictedValue() Regression java.lang.Double.NaN

Depending on the type of mining model that is used, different sets of fields are computed. After you specify a mining model with one of the openModel(...) methods, you can query the type of mining model by using the method public int getModelType(). This method returns an integer value that represents one of the following constants:

With getModelType(), it is possible to determine which of the methods listed in Table 15 can be used to access the computed result fields. If the model type is, for example, Scorer.CLASSIFICATION_TYPE, the scoring result can be accessed with the methods getPredictedClass() and getConfidence(). The use of the method getPredictedValue() in this context, for example, would throw a ResultException. Each of the result methods throws a ResultException whenever the result field and the actual model type do not fit together.

It might be the case that a mining model is specified, but the model is not loaded yet or the score method is not called yet. In this case, the result methods that fit the specified model type return their default values as listed in Table 15.

Scoring example

 
0	try {
1     RecordScorer scorer = new RecordScorer( "93er_cars.pmml" );
2     int modelType = scorer.getModelType(); 
3     double predictedValue = getPredictedValue();
4     try { 
5        int predictedClass = scorer.getPredictedClass(); 
6     } catch ( ResultException e ) {
7        // this is an expected exception for illustration purposes 
8     }
9     HashMap record = new HashMap(); 
10    record.put("Horsepower", new Integer(200)); 
11    record.put("Air Bags standard", new Integer(2) ); 
12    record.put("City MPG", new Integer(17) ); 
13    scorer.score( record ); 				
14    predictedValue = scorer. getPredictedValue(); 
15		 
16	}  catch ( Exception e ) {
17    // should not occur if everything is correct
18 }
 

First, a new RecordScorer instance is initialized with a Stepwise Polynomial Regression mining model (line 1). The value of modelType in line 2 thus is equal to the value specified by the constant Scorer.REGRESSION_TYPE. For this type of model, a predicted value is expected for each scored record. When the method getPredictedValue() is called in line 3, the actual predicted value is returned. Since the score(Map) method is not called yet, the default value NaN is returned by the method in line 3. When getPredictedClass() is called in line 5, a ResultException is thrown, because the predicted class for the result field does not fit the model type Scorer.REGRESSION_TYPE. In line 9 to 12, the actual data record is defined. There, the field names are mapped to their actual values. In line 13, score(Map) is called and the scoring result is computed. The result of the call to getPredictedValue() in line 14 is a value not equal to NaN, the default value.

ScoringException classes

The following exception classes are used by the RecordScorer and its base class Scorer:

ModelException
Used if an error occurred that was relevant to the mining model that was specified.
RecordException
Used if an error occurred that was relevant to the data record that was used.
ResultException
Used if an error occurred that was relevant to the result fields that were computed.

In addition, the RecordScorer constructor and the openModel method, which read the model from a database table, can throw a:

java.sql.SQLException

This exception provides information on a database access error or other errors.

Reference

Utility functions provided by IM Scoring
Data types reference
Functions and stored procedures reference
DM_applData
DM_applyClasModel
DM_applyClusModel
DM_applyRegModel
DM_expClasModel
DM_expClusModel
DM_expDataSpec
DM_expRegModel
DM_getClasCostRate
DM_getClasMdlName
DM_getClasMdlSpec
DM_getClasTarget
DM_getClusConf
DM_getClusMdlName
DM_getClusMdlSpec
DM_getClusMdlType
DM_getClusScore
DM_getClusterID
DM_getClusterName
DM_getConfidence
DM_getFldName
DM_getFldType
DM_getNumClusters
DM_getNumFields
DM_getPredClass
DM_getPredValue
DM_getQuality
DM_getQuality(clusterid)
DM_getRBFRegionID
DM_getRegMdlName
DM_getRegMdlSpec
DM_getRegTarget
DM_impApplData
DM_impApplDataLarge
DM_impClasFile
DM_impClasFileE
DM_impClasModel
DM_impClusFile
DM_impClusFileE
DM_impClusModel
DM_impDataSpec
DM_impRegFile
DM_impRegFileE
DM_impRegModel
DM_isCompatible
PredictClass
PredictClassConf
PredictClusConf
PredictClusterID
PredictClusQuality
PredictClusScore
PredictValue
IM Scoring utilities reference
DM_initialize
DM_memoryFree
DM_printenv
DM_printModelCache
DM_setEnv
Command reference
The idm_setup command
The idm_uninstall command
The idmlevel command
The idmlicm command
The idmmkSQL command
The idmxmod command

Utility functions provided by IM Scoring

IM Scoring provides some utility functions that are used together with the scoring functions, for example, to initialize scoring functions, or to control the tracing process. The utility functions are installed in package IDMMX.

Table 16. Utility functions specific to IM Scoring
Utility function Purpose Page
DM_initialize Performs initialization for a user account to enable the application functions for this user. Must be called once per Oracle user. DM_initialize
DM_memoryFree Clears the model cache, and closes any error files or trace files that are open. DM_memoryFree
DM_printenv Displays currently defined environment variables and their values. DM_printenv
DM_printModelCache Displays the names of the models that are currently in the model cache. DM_printModelCache

Data types reference

IM Scoring provides a number of user-defined data types. These data types are used to store models and results, and to define the data to which a model is applied.

Most of the new data types (UDTs) are aliases for built-in Oracle data types. These aliases are defined in the package IDMMX, but they are not visible outside the package. These UDTs are logical types explaining the kind of data a UDF needs or returns. Therefore, you must use the source data types if you want to create a table with columns that are associated with these aliases.

However, the UDTs DM_ApplColumn, DM_ApplRow, and DM_LogicalDataSpec are not aliases but object data types. They are defined in the schema IDMTY and are publicly visible. You can use them by qualifying their name with the schema prefix IDMTY.

Table 17. Data types specific to IM Scoring
Data type (UDT) Source data type Purpose Functions (UDF)
DM_ApplColumn Object type with elements:

label: VARCHAR2(64)

charValue: VARCHAR2(128)

numValue: NUMBER

Contains a label for a field defined in a model and the value of that field for the currently applied data record. charValue and numValue can be used alternatively. It must always be used together with DM_ApplRow.
DM_ApplRow Object type with elements:

Table of DM_ApplColumn

Contains a list of DM_ApplColumn objects. Used to collect the DM_ApplColumn objects that contain the application data and to pass them to DM_applData or directly to the application functions.

Functions:

DM_impApplData

DM_applyClasModel

DM_applyClusModel

DM_applyRegModel

DM_impApplDataLarge

DM_ApplicationData VARCHAR2 Distinct type: It contains the definition of data to which a model is applied.

Functions:

DM_applData

DM_applyClasModel

DM_applyClusModel

DM_applyRegModel

DM_impApplData

DM_ApplicationDataLarge CLOB Distinct type: It contains the definition of data to which a model is applied.

Functions:

DM_impApplDataLarge

DM_applyClasModel

DM_applyClusModel

DM_applyRegModel

DM_ClasModel BLOB Distinct type: It identifies data within Oracle as a Tree or Neural Classification model. The data type is associated with the model when the model is imported using the DM_impClasFile function. If the model is stored in a database table, the column must be configured for this data type.

Functions:

DM_applyClasModel

DM_expClasModel

DM_getClasMdlName

DM_getClasCostRate

DM_getClasMdlSpec

DM_getClasTarget

DM_impClasFile

DM_impClasFileE

DM_impClasModel

DM_ClasResult VARCHAR2 Distinct type: It contains the predicted class and classification confidence values for a row of data obtained when a Classification model is applied by means of the DM_applyClasModel function.

Functions:

DM_applyClasModel

DM_getConfidence

DM_getPredClass

DM_ClusResult VARCHAR2 Distinct type: It contains computed cluster ID, score, confidence, and quality for a row of data obtained when a Clustering model is applied by means of the DM_applyClusModel function.

Functions:

DM_applyClusModel

DM_getClusConf

DM_getClusScore

DM_getClusterID

DM_getQuality

DM_getQuality(clusterid)

DM_ClusteringModel BLOB Distinct type: It identifies data within Oracle as a Demographic or Center-based Clustering model. The data type is associated with the model when the model is imported by means of the DM_impClusFile function. If the model is stored in a database table, the column must be configured for this data type.

Functions:

DM_applyClusModel

DM_expClusModel

DM_getClusMdlName

DM_getClusMdlSpec

DM_getClusMdlType

DM_getNumClusters

DM_getClusterName

DM_impClusFile

DM_impClusFileE

DM_impClusModel

DM_LogicalDataSpec CLOB Object type: It identifies the field names and types that are contained in a model and that are needed to apply a model.

Functions:

DM_expDataSpec

DM_getFldName

DM_getFldType

DM_getNumFields

DM_impDataSpec

DM_isCompatible

DM_getClasMdlSpec

DM_getClusMdlSpec

DM_getRegMdlSpec

DM_RegressionModel BLOB Distinct type: It identifies data within Oracle as:
  • An RBF or Neural Regression model
  • Transform Regression model
The data type is associated with the model when the model is imported by means of the DM_impRegFile function. If the model is stored in a database table, the column must be configured for this data type.

Functions:

DM_applyRegModel

DM_expRegModel

DM_getRegMdlName

DM_getRegMdlSpec

DM_getRegTarget

DM_impRegFile

DM_impRegFileE

DM_impRegModel

DM_RegResult VARCHAR2 Distinct type: It contains the predicted value for a row of data obtained when a Regression model is applied by means of the DM_applyRegModel function. For RBF models it also contains the region ID.

Functions:

DM_applyRegModel

DM_getPredValue

DM_getRBFRegionID

Note:
You might create a table with a column of data type DM_ClusResult, DM_ClasResult, or DM_RegResult (source data type VARCHAR2). In this case, a column length of 512 is sufficient. This will hold the character string returned by the UDFs that use these data types for their return values.

Functions and stored procedures reference

This chapter contains full descriptions of all the IM Scoring functions and stored procedures. They are presented in alphabetical order of the function names.

IM Scoring provides a number of user-defined scoring functions that enable you to:

  1. Import and export mining models, and access the properties of the models.
  2. Apply these models to data held in Oracle tables.
  3. Retrieve the results.

The scoring functions are installed in the package IDMMX.

For more information refer to Data types reference.

For instructions on how to use the database objects presented here, see Using IM Scoring.

For instructions on how to read the syntax diagrams, see How to read the syntax diagrams.

DM_applData

This function obtains the data to which a model is applied by DM_applyClusModel, DM_applyClasModel, or DM_applyRegModel. It builds a value of type DM_ApplicationData, which includes the label and the value obtained from the column specified in the SQL statement.

This function is available in two different notations. One notation has two parameters; the other has three parameters. Use the two-parameter notation for the inner call in nested calls, or if the application data consists only of one field-value pair.

Syntax

Read syntax diagramSkip visual syntax diagramTwo-parameter notation

>>-DM_applData--(--label--,--+-character expression-+--)-------><
                             '-numeric expression---'

Read syntax diagramSkip visual syntax diagramThree-parameter notation

>>-DM_applData--(--application data--,--label--,---------------->

>--+-character expression-+--)---------------------------------><
   '-numeric expression---'

Parameters

application data
Identifies application data of type DM_ApplicationData to which the label and value of the expression are appended before being returned. In nested calls, this parameter is the return value of a DM_applData call.
label
The label is a literal and must be defined within single quotation marks. The string enclosed within the quotation marks must be a precise match, including case, for the name of a field defined in the model you apply. Together with the character or numeric expression that follows, this forms the data to which a model is applied. It will be appended to the DM_ApplicationData value.

Label can have a maximum length of 64.

character expression
An expression that returns a value of type CHAR or VARCHAR2.
Note:
IM for Data handles date values and time values in character ISO format. If you want to specify a date value or a time value as input to DM_applData and you want to apply a model created by IM for Data, the date value and time value must be cast to character ISO format by using TO_CHAR(<value>,'YYYY-MM-DD') for a date value and TO_CHAR(<value>,'HH24:MI:SS') for a time value.
numeric expression
An expression that returns a value of type NUMBER, or an expression that is automatically converted to type NUMBER by Oracle. For example, you can include an expression such as age + 10.

If multiple data items are to be included, multiple nested calls to DM_applData must be made.

Return value

The return value is a value of data type DM_ApplicationData.

Related concepts

Examples

An example is provided in:

DM_applyClasModel

This function applies a Classification model to selected data and produces results.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_applyClasModel--(--model--,--application data--)---------><

Parameters

model
The Classification model of type DM_ClasModel that is to be applied to data
application data
Specifies the data of type DM_ApplicationData, DM_ApplicationDataLarge, or DM_ApplRow to which the model is applied. A DM_ApplicationData value is returned by DM_applData or DM_impApplData. A DM_ApplicationDataLarge value is returned by DM_impApplDataLarge. See DM_applData, DM_impApplDataLarge, and DM_impApplData.

Return value

The results produced by applying a model using DM_applyClasModel are returned as data type DM_ClasResult.

If model or application data is NULL, the return value is NULL.

DM_applyClusModel

This function applies a Clustering model to selected data and produces results.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_applyClusModel--(--model--,--application data--)---------><

Parameters

model
The Clustering model of type DM_ClusteringModel that is to be applied to data.
application data
Specifies the data of type DM_ApplicationData, DM_ApplicationDataLarge, or DM_ApplRow to which the model is applied. A DM_ApplicationData value is returned by DM_applData or DM_impApplData. A DM_ApplicationDataLarge value is returned by DM_impApplDataLarge. See DM_applData, DM_impApplDataLarge, and DM_impApplData.

Return value

The results produced by applying a model using DM_applyClusModel are returned as data type DM_ClusResult.

If the input model is a Distribution-based Clustering model that does not contain distance units, they are calculated by default for numeric fields. The default value is half of the square root of the variance of the field.

If model or application data is NULL, the return value is NULL.

DM_applyRegModel

This function applies a Regression model to selected data and produces results.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_applyRegModel--(--model--,--application data--)----------><

Parameters

model
The Regression model of type DM_RegressionModel that is to be applied to data.
application data
Specifies the data of type DM_ApplicationData, DM_ApplicationDataLarge, or DM_ApplRow to which the model is applied. A DM_ApplicationData value is returned by DM_applData or DM_impApplData. A DM_ApplicationDataLarge value is returned by DM_impApplDataLarge. See DM_applData, DM_impApplDataLarge, and DM_impApplData.

Return value

The results produced by applying a model using DM_applyRegModel are returned as data type DM_RegResult.

If model or application data is NULL, the return value is NULL.

DM_expClasModel

This function returns a character large object representing a PMML Classification model of type DM_ClasModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_expClasModel--(--classificationModel--)------------------><

Parameters

classificationModel
A value of type DM_ClasModel

Return value

The return value is a character large object representing the PMML Classification model in question. The CLOB XML string is encoded in database encoding (the code set specified when the database was created) regardless of the encoding specification found in the XML content.

DM_expClusModel

This function returns a character large object representing the PMML Clustering model extracted from a value of type DM_ClusteringModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_expClusModel--(--clusteringModel--)----------------------><

Parameters

clusteringModel
A value of type DM_ClusteringModel

Return value

The return value is a character large object representing the Clustering model. The CLOB XML string is encoded in database encoding (the code set specified when the database was created) regardless of the encoding specification found in the XML content.

DM_expDataSpec

This function converts a value of type DM_LogicalDataSpec to a CLOB value, and returns it.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_expDataSpec--(--fields--)--------------------------------><

Parameters

fields
A value of type DM_LogicalDataSpec

Return value

The return value is a CLOB value converted from fields.

DM_expRegModel

This function returns a character large object representing a PMML or XML Regression model of type DM_RegressionModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_expRegModel--(--regressionModel--)-----------------------><

Parameters

regressionModel
A value of type DM_RegressionModel

Return value

A character large object (CLOB) represents a Regression model, if it is a valid instance of the PMML-based regression DTD according to XML.

The return value is a character large object (CLOB) representing the Regression model. The CLOB XML string is encoded in the code set, which is specified when the database is created, regardless of the encoding specification found in the XML content.

Note:
XML Regression models created by IM Modeling are not fully PMML 2.1 compliant models. They use existing PMML 2.1 element names with several minor additions. These additions have been submitted to be part of the next PMML 3.0 standard.

DM_getClasCostRate

This function returns the classification cost rate of the Classification model computed in a validation phase during the training phase. It uses the validation data specified in the DM_ClasBldTask value (an IM Modeling structured type that defines a modeling task).

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClasCostRate--(--classificationModel--)---------------><

Parameters

classificationModel
A value of type DM_ClasModel

Return value

Related concepts

Extracting information from a model

DM_getClasMdlName

This function returns the name of a Classification model of type DM_ClasModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClasMdlName--(--classificationModel--)----------------><

Parameters

classificationModel
A Classification model of the type DM_ClasModel

Return value

The return value is the name of the Classification model as a VARCHAR2 value.

Related concepts

Extracting information from a model

DM_getClasMdlSpec

This function returns the DM_LogicalDataSpec value representing the set of fields needed for an application of the Classification model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClasMdlSpec--(--classificationModel--)----------------><

Parameters

classificationModel
A value of type DM_ClasModel

Return value

The return value is the DM_LogicalDataSpec value representing the set of fields needed for an application of the Classification model.

Related concepts

Extracting information from a model

DM_getClasTarget

This function returns the name of the target field of a Classification model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClasTarget--(--classificationModel--)-----------------><

Parameters

classificationModel
A value of type DM_ClasModel

Return value

The return value is the target field name as a VARCHAR2 value.

Related concepts

Extracting information from a model

DM_getClusConf

This function returns the confidence of attributing the record r to the best cluster in comparison with attributing it to another cluster of the applied model. The ID of the best cluster is returned by the function DM_getClusterID.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClusConf--(--results value--)-------------------------><

Parameters

results value
The result of applying a Clustering model, returned by function DM_applyClusModel as data type DM_ClusResult

Return value

The confidence is a value between 0 and 1 of type NUMBER. A value near 0 should never appear. A value near 0.5 (50%) means that the record might fit equally well into another cluster of the model. A value near 1 means that it is quite certain that the record belongs to the best cluster. It also means that the record definitely does not suit any other clusters of the model.

Related concepts

Getting application results

DM_getClusMdlName

This function returns the name of a Clustering model of type DM_ClusteringModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClusMdlName--(--clusteringModel--)--------------------><

Parameters

clusteringModel
A Clustering model of the type DM_ClusteringModel

Return value

The return value is the name of the Clustering model as a VARCHAR2 value.

Related concepts

Extracting information from a model

Examples

Extracting information from a model

DM_getClusMdlSpec

This function returns the DM_LogicalDataSpec value representing the set of fields needed for an application of the Clustering model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClusMdlSpec--(--clusteringModel--)--------------------><

Parameters

clusteringModel
A value of type DM_ClusteringModel

Return value

The return value is the DM_LogicalDataSpec value representing the set of fields needed for an application of the Clustering model.

Examples

Extracting information from a model

DM_getClusMdlType

This function obtains the type of a Clustering model of type DM_ClusteringModel as defined in PMML.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClusMdlType--(--clusteringModel--)--------------------><

Parameters

clusteringModel
A value of type DM_ClusteringModel

Return value

The return value is the type of the Clustering model as a VARCHAR value. It can be center-based or distribution-based.

DM_getClusScore

This function obtains the Clustering quality from results data that is produced when you apply a Clustering model. The score is an expression of how closely the data matches the model cluster. For Distribution-based Clustering , a score value close to 1.0 indicates a good match. For Center-based Clustering, a score value close to 0.0 indicates a good match.

For more information refer to DM_getQuality.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClusScore--(--results value--)------------------------><

Parameters

results value
The result of applying a Clustering model, returned by function DM_applyClusModel as data type DM_ClusResult

Return value

Related concepts

Getting application results

DM_getClusterID

This function obtains the cluster ID from results data that is produced when you apply a Clustering model. The cluster ID identifies the position of the cluster in the Clustering model that is the best match for this data. For information about the difference between the cluster IDs that are returned by IM Scoring V7.1 and IM Scoring V8.2, see Using the function DM_getClusterID.

Use DM_getClusterName to get the cluster name shown by the IM for Data Clustering Visualizer.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClusterID--(--results value--)------------------------><

Parameters

results value
The result of applying a Clustering model, returned by function DM_applyClusModel as data type DM_ClusResult

Return value

Related concepts

Getting application results

Examples

Examples are provided in:

DM_getClusterName

This function returns the name of a cluster at a specified position in a value of type DM_ClusteringModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getClusterName--(--clusteringModel--,--position--)-------><

Parameters

clusteringModel
A value of type DM_ClusteringModel
position
A value, of type INTEGER, between 1 and the result of DM_getNumClusters. Here you can specify the value obtained by a call to DM_getClusterID.

Return value

Related concepts

Extracting information from a model

DM_getConfidence

This function obtains the classification confidence value from results data that was produced when you applied a Classification model. This is a value between 0.0 and 1.0 that expresses the probability that the class is predicted correctly.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getConfidence--(--results value--)-----------------------><

Parameters

results value
The result of applying a Classification model, returned by the function DM_applyClasModel as data type DM_ClasResult

Return value

Related concepts

Getting application results

DM_getFldName

This function returns the name of a field at a specified position in a value of type DM_LogicalDataSpec.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getFldName--(--fields--,--position--)--------------------><

Parameters

fields
A value of type DM_LogicalDataSpec
position
An INTEGER value, ranging from 1 to the number of fields, that specifies the position

Return value

Examples

Examples are provided in:

DM_getFldType

This function returns the mining field type of a specified field that is contained in a value of type DM_LogicalDataSpec.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getFldType--(--fields--,--fieldName--)-------------------><

Parameters

fields
A value of type DM_LogicalDataSpec
fieldName
A field name, of type VARCHAR2, that is already contained in fields

The DM_LogicalDataSpec data type contains the set of input fields of a mining model, created by one of the functions DM_getClusMdlSpec, DM_getClasMdlSpec, or DM_getRegMdlSpec. An input field is defined by a name and a type. The type can be either DM_Categorical or DM_Numerical.

Table 18. Mining field types
Mining data field type name Mining field type value Source data type
DM_Categorical 0 CHAR, VARCHAR2, and ANSI data types that are converted to CHAR or VARCHAR2
DM_Numerical 1 NUMBER and ANSI data types that are converted to NUMBER

Return value

DM_getNumClusters

This function returns the number of clusters contained in a value of type DM_ClusteringModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getNumClusters--(--clusteringModel--)--------------------><

Parameters

clusteringModel
A value of type DM_ClusteringModel

Return value

Related concepts

Extracting information from a model

Examples

Extracting information from a model

DM_getNumFields

This function returns the number of fields that are contained in a value of type DM_LogicalDataSpec

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getNumFields--(--fields--)-------------------------------><

Parameters

fields
A value of type DM_LogicalDataSpec

Return value

The number of fields, as type INTEGER, that are contained in fields.

DM_getPredClass

This function obtains the predicted class from results data that is produced when you apply a Classification model. This identifies the class within the model to which the data matches.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getPredClass--(--results value--)------------------------><

Parameters

results value
The result of applying a Classification model, returned by the function DM_applyClasModel as data type DM_ClasResult

Return value

Related concepts

Getting application results

DM_getPredValue

This function obtains the predicted value from results data that is produced when you apply a Regression model. This value is calculated according to relations that are established by the model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getPredValue--(--results value--)------------------------><

Parameters

results value
The result of applying a Regression model, returned by the function DM_applyRegModel as data type DM_RegResult

Return value

Related concepts

Getting application results

DM_getQuality

This function returns the quality of attributing the record to the best cluster whose ID is given by the function DM_getClusterID. It measures how well the applied record fits into the best cluster.

The returned value is between 0.0 and 1.0. A value close to 0.0 means that the record does not fit at all in the best cluster. A value close to 1.0 means that the record fits very well in the best cluster. The quality measurement depends on the algorithm used to score the record, so that a direct comparison between the quality of algorithm results is not possible. However, both center-based and distribution-based algorithms use a linear, possibly similar, quality measurement function.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getQuality--(--results value--)--------------------------><

Parameters

results value
The result of applying a Clustering model, returned by the function DM_applyClusModel as data type DM_ClusResult

Return value

Related concepts

Getting application results

DM_getQuality(clusterid)

This function returns the quality of the result for a specified cluster. It measures how well the applied record fits into the specified cluster.

The result may not contain a quality measure for all the available clusters. IM Scoring V8 usually computes the quality measure for only the two best matching clusters; it does this in order to optimize the memory needed to store the clustering result.

The returned value is between 0.0 and 1.0. A value close to 0.0 means that the record does not fit at all in the cluster. A value close to 1.0 means that the record fits very well in the specified cluster. The quality measurement depends on the algorithm used to score the record, so that a direct comparison between the quality of algorithm results is not possible. However, both algorithms use a linear, possibly similar, quality measurement function.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getQuality--(--results value--,--clusterid--)------------><

Parameters

results value
The result of applying a Clustering model, returned by the function DM_applyClusModel as data type DM_ClusResult
clusterid
The ID of the cluster for which the quality should be returned

Return value

DM_getRBFRegionID

This function returns the number of the region to which the record was assigned. The value is returned from results data that is produced when you apply an RBF Regression model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getRBFRegionID--(--results value--)----------------------><

Parameters

results value
The results of applying an RBF Regression model returned by the function DM_applyRegModel as data type DM_RegResult

Return value

Related concepts

Getting application results

DM_getRegMdlName

This function returns the name of a Regression model of type DM_RegressionModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getRegMdlName--(--regressionModel--)---------------------><

Parameters

regressionModel
A Regression model of the type DM_RegressionModel

Return value

The return value is the name of the Regression model as a VARCHAR2 value.

Related concepts

Extracting information from a model

DM_getRegMdlSpec

This function returns the DM_LogicalDataSpec value representing the set of fields needed for an application of the Regression model. The field names contained in the DM_LogicalDataSpec value are the field names of the DM_LogicalDataSpec value used for building the Regression model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getRegMdlSpec--(--regressionModel--)---------------------><

Parameters

regressionModel
A value of type DM_RegressionModel

Return value

The return value is the DM_LogicalDataSpec value representing the set of fields needed for an application of the Regression model.

DM_getRegTarget

This function returns the name of the target field used when training the Regression model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_getRegTarget--(--regressionModel--)----------------------><

Parameters

regressionModel
A value of type DM_RegressionModel

Return value

The target field name is returned as a value of type VARCHAR2.

Related concepts

Extracting information from a model

DM_impApplData

This function converts a data record of type CLOB, CHAR, VARCHAR2, or DM_ApplRow into type DM_ApplicationData.

Note:
The XML string returned by DM_impApplData must not exceed 4 KB, because DM_ApplicationData is implemented as VARCHAR2.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impApplData--(--+-data record as string-----+--)---------><
                      '-data record as DM_ApplRow-'

Parameters

data record as string
Is a value of CLOB, CHAR, or VARCHAR2.

The data record must be a well-formed XML element. The element must match the DTD declaration of type row below:

 
<!ELEMENT row     (column*)   >
<!ELEMENT column  (PCDATA)    >
<!ATTLIST column
     name CDATA #REQUIRED
     null (true | false ) "false"
>

A value of the attribute name is interpreted as the name of the scoring field. The content of an element is interpreted as the value of the named scoring field. The order of the column elements is not relevant. The data for some fields might be NULL. In this case, it is represented by an element where the attribute null has the value true and the content is empty.

data record as DM_ApplRow
Data record is a value of DM_ApplRow value.

An object of type DM_ApplRow can store an arbitrary number of objects of type DM_ApplColumn. DM_ApplColumn objects store a label of type VARCHAR2, a value of type VARCHAR2, and another value of type NUMBER. The label corresponds to the value of the attribute name in the XML representation. The character value or numeric value (used alternatively) corresponds to the content of the XML element column(PCDATA). DM_ApplRow and DM_ApplColumn are used by calling their constructors as follows:

 
IDMTY.DM_ApplRow(IDMTY.DM_ApplColumn(<label>, <char value or NULL>, 
                 <numeric value or NULL>),
                 ...
                 IDMTY.DM_ApplColumn(<label>, <char value or NULL>, 
                 <numeric value or NULL>))

If the char value is used in the constructor of DM_ApplColumn, the numeric value must be NULL, and vice versa.

Return value

Related concepts

Examples

Examples are provided in:

DM_impApplDataLarge

This function converts a data record of type DM_ApplRow into type DM_ApplicationDataLarge.

Note:
This function is similar to the function DM_impApplData, however, the returned XML string can be longer than 4 KB.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impApplDataLarge--(--data record as DM_ApplRow--)--------><

Parameters

data record as DM_ApplRow
Data record is a value of DM_ApplRow value.

An object of type DM_ApplRow can store an arbitrary number of objects of type DM_ApplColumn. DM_ApplColumn objects store a label of type VARCHAR2, a value of type VARCHAR2, and another value of type NUMBER. The label corresponds to the value of the attribute name in the XML representation. The character value or numeric value (used alternatively) corresponds to the content of the XML element column (PCDATA). DM_ApplRow and DM_ApplColumn are used by calling their constructors as follows:

 
IDMTY.DM_ApplRow(IDMTY.DM_ApplColumn(<label>, <char value or NULL>, 
                 <numeric value or NULL>),
                 ...
                 IDMTY.DM_ApplColumn(<label>, <char value or NULL>, 
                 <numeric value or NULL>))

If the char value is used in the constructor of DM_ApplColumn, the numeric value must be NULL, and vice versa.

Return value

Usage notes

Here you find more information about the differences between the source data types of DM_ApplicationData and DM_ApplicationDataLarge:

When specifying the apply function, it is recommended that you assemble your SQL statement as follows. If the returned XML string does not exceed 32 KB (which is the limit of the string length of the PL/SQL engine), you can specify the application data without DM_impApplData, for example:

DM_applyClusModel ( model , application data )
Note:
Specify DM_impApplDataLarge only if the 32 KB limit is exceeded. This is indicated by the following error message:

ORA-06502: PL/SQL: numeric or value error: character string buffer too small


Related concepts

Examples

Examples are provided in:

DM_impClasFile

This function reads a Classification model from a file, and returns it as data of type DM_ClasModel. This data can then be inserted into a table where one of the columns is designated for this data type.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impClasFile--(--input file name--)-----------------------><

Parameters

input file name
The name and full path of the file to be imported. The specified file must:
  • Exist on the database server and the account or user who owns the Oracle instance must have read access to the file.
  • Have a supported format, for more information refer to Importing mining models.

Return value

The return value is the imported model as data type DM_ClasModel.

Related concepts

Importing mining models

Usage

The encoding of characters in the imported file is determined by default. For information about the default encoding rules, see DM_impClasFileE. The call

 
DM_impClasFile(filename)

corresponds to

 
DM_impClasFileE(filename, NULL)

When the content of the file is read and imported into Oracle, the file is no longer needed. However, you might want to keep the file in case you need to import the model again.

DM_impClasFileE

This function reads a Classification model from a file, and returns it as data of type DM_ClasModel. This data can then be inserted into a table where one of the columns is designated for this data type.

The encoding of characters in the imported file is specified by a parameter.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impClasFileE--(--input file name--,--encoding name--)----><

Parameters

input file name
The name and full path of the file to be imported. The specified file must:
  • Exist on the database server and the account or user who owns the Oracle instance must have read access to the file.
  • Have a supported format, for more information refer to Importing mining models.
encoding name

IM Scoring supports different encoding names. The MIME encoding strings are recommended, for example, iso-8859-1.

  • If the encoding name is a non-empty string, the value is interpreted as an XML encoding. The content of the imported file is parsed according to this encoding. The imported file must be a PMML document.
  • If the encoding name is the string 'SYSTEM', the locale settings of the operating system are used to determine the encoding of the file.
  • If the encoding name is NULL, the encoding is determined by the imported file.

    • If the file is a PMML document, the standard rules of the XML specification apply. That is, the encoding is either given explicitly or assumed to be Unicode by default.
    • If the imported file is written in Intelligent Miner format, the locale settings of the operating system are used.

Usage

When the content of the file is read and imported into Oracle, the file is no longer needed. However, you might want to keep the file in case you need to import the model again.

Return value

The return value is the imported model as data type DM_ClasModel.

Related concepts

Importing mining models

Examples

DM_impClasFile

DM_impClasModel

This function converts the Classification model given as CLOB into a Classification model of type DM_ClasModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impClasModel--(--model_as_CLOB--)------------------------><

Parameters

model_as_CLOB
A Classification model in PMML format as a CLOB value. The model is assumed to be provided in database encoding (the code set specified when the database was created), regardless of the XML encoding specification contained in the model.

Return value

The return value is a Classification model of type DM_ClasModel. If model_as_CLOB is NULL, the return value is NULL.

Related concepts

Importing mining models

DM_impClusFile

This function reads a Demographic or Center-based Clustering model from a file, and returns it as data of type DM_ClusteringModel. This data can then be inserted into a table where one of the columns is designated for this data type.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impClusFile--(--input file name--)-----------------------><

Parameters

input file name
The name and full path of the file to be imported. The specified file must:
  • Exist on the database server and the account or user who owns the Oracle instance must have read access to the file.
  • Have a supported format, for more information refer to Importing mining models.

Return value

The return value is the imported model as data type DM_ClusteringModel.

If the input model is a Distribution-based Clustering Model that does not contain distance units, they are calculated by default for numeric fields. The default value is half the square root of the variance of the field.

Usage

The encoding of characters in the imported file is determined by default. For information about the default encoding rules, see DM_impClusFileE. The call

 
DM_impClusFile(filename)

corresponds to

 
DM_impClusFileE(filename, NULL)

When the content of the file is read and imported into Oracle, the file is no longer needed. However, you might want to keep the file in case you need to import the model again.

Related concepts

Importing mining models

Examples

Examples are provided in:

DM_impClusFileE

This function reads a Demographic or Center-based Clustering model from a file, and returns it as data of type DM_ClusteringModel. This data can then be inserted into a table where one of the columns is designated for this data type.

The encoding of characters in the imported file is specified by a parameter.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impClusFileE--(--input file name--,--encoding name--)----><

Parameters

input file name
The name and full path of the file to be imported. The specified file must:
  • Exist on the database server and the account or user who owns the Oracle instance must have read access to the file.
  • Have a supported format, for more information refer to Importing mining models.
encoding name

IM Scoring supports different encoding names. The MIME encoding strings are recommended, for example, iso-8859-1.

  • If the encoding name is a non-empty string, the value is interpreted as an XML encoding. The content of the imported file is parsed according to this encoding. The imported file must be a PMML document.
  • If the encoding name is the string 'SYSTEM', the locale settings of the operating system are used to determine the encoding of the file.
  • If the encoding name is NULL, the encoding is determined by the imported file.

    • If the file is a PMML document, the standard rules of the XML specification apply. That is, the encoding is either specified explicitly or assumed to be Unicode by default.
    • If the imported file is written in Intelligent Miner format, the locale settings of the operating system are used.

Return value

The return value is the imported model as data type DM_ClusteringModel.

If the input model is a Distribution-based Clustering model that does not contain distance units, they are calculated by default for numeric fields. The default value is half the square root of the variance of the field.

Usage

When the content of the file is read and imported into Oracle, the file is no longer needed. However, you might want to keep the file in case you need to import the model again.

Related concepts

Importing mining models

Examples

Examples are provided in:

DM_impClusModel

This function converts a Clustering model given as a CLOB value into a Clustering model of type DM_ClusteringModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impClusModel--(--model_as_CLOB--)------------------------><

Parameters

model_as_CLOB
A Clustering model in PMML format as a CLOB value. The model is assumed to be provided in database encoding (the code set specified when the database was created), regardless of the XML encoding specification contained in the model.

Return value

The return value is a Clustering model of type DM_ClusteringModel. If model_as_CLOB is NULL, the return value is NULL.

Related concepts

Importing mining models

Examples

Importing mining models from a CLOB value in a database table

DM_impDataSpec

This function converts a CLOB value to a value of type DM_LogicalDataSpec. The CLOB value must be a value that was previously exported using the DM_expDataSpec function.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impDataSpec--(--fields--,--logDataSpec--)----------------><

Parameters

fields
A value of type DM_LogicalDataSpec
logDataSpec
A CLOB value containing logical data specifications

Return value

The return value is fields containing the content of logDataSpec. Any existing definitions in fields are overwritten by the content of logDataSpec.

If logDataSpec is NULL, the return value is NULL.

DM_impRegFile

This function reads an RBF model, a Neural Regression model, a Polynomial Regression model, or a Transform Regression model from a file, and returns it as data of type DM_RegressionModel. This data can then be inserted into a table where one of the columns is designated for this data type.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impRegFile--(--input file name--)------------------------><

Parameters

input file name
The name and full path of the file to be imported. The specified file must:
  • Exist on the database server and the account or user who owns the Oracle instance must have read access to the file.
  • Have a supported format, for more information refer to Importing mining models.

Return value

The return value is the imported model as data type DM_RegressionModel.

Related concepts

Importing mining models

Usage

The encoding of characters in the imported file is determined by default. For information about the default encoding rules, see DM_impRegFileE . The call

 
DM_impRegFile(filename)

corresponds to

 
DM_impRegFileE(filename, NULL)

When the content of the file is read and imported into Oracle, the file is no longer needed. However, you might want to keep the file in case you need to import the model again.

DM_impRegFileE

This function reads an RBF model, a Neural Regression model, a Polynomial Regression model, or a Transform Regression model from a file, and returns it as data of type DM_RegressionModel. This data can then be inserted into a table where one of the columns is designated for this data type.

The encoding of characters in the imported file is specified by a parameter.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impRegFileE--(--input file name--,--encoding name--)-----><

Parameters

input file name
The name and full path of the file to be imported. The specified file must:
  • Exist on the database server and the account or user who owns the Oracle instance must have read access to the file.
  • Have a supported format, for more information refer to Importing mining models.
encoding name

IM Scoring supports different encoding names. The MIME encoding strings are recommended, for example, iso-8859-1.

  • If the encoding name is a non-empty string, the value is interpreted as an XML encoding. The content of the imported file is parsed according to this encoding. The imported file must be a PMML document.
  • If the encoding name is the string 'SYSTEM', the locale settings of the operating system are used to determine the encoding of the file.
  • If the encoding name is NULL, the encoding is determined by the imported file.

    • If the file is a PMML document, the standard rules of the XML specification apply. That is, the encoding is either specified explicitly or assumed to be Unicode by default.
    • If the imported file is written in Intelligent Miner format, the locale settings of the operating system are used.

Return value

The return value is the imported model as data type DM_RegressionModel.

Usage

When the content of the file is read and imported into Oracle, the file is no longer needed. However, you might want to keep the file in case you need to import the model again.

Related concepts

Importing mining models

Examples

DM_impRegFile

DM_impRegModel

This function converts a Regression model given as CLOB into a Regression model of type DM_RegressionModel.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_impRegModel--(--model_as_CLOB--)-------------------------><

Parameters

model_as_CLOB
A Regression model in PMML format as a CLOB value. The model is assumed to be provided in database encoding (the code set specified when the database was created), regardless of the XML encoding specification contained in the model.

Return value

The return value is a Regression model of type DM_RegressionModel. If model_as_CLOB is NULL, the return value is NULL.

Related concepts

Importing mining models

DM_isCompatible

This function determines whether a DM_LogicalDataSpec value is compatible with another DM_LogicalDataSpec value.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_isCompatible--(--existLogDataSpec--,--logDataSpec--)-----><

Parameters

existLogDataSpec
A value of type DM_LogicalDataSpec
logDataSpec
A value of type DM_LogicalDataSpec to be checked for compatibility

Return value

Note:
Calls to DM_isCompatible are not symmetric. A call DM_isCompatible(A,B) can return a result different from that returned by DM_isCompatible(B,A).

PredictClass

This function obtains the predicted class from results data that is produced when you apply a Classification model. This identifies, within the model, the particular class that matches the data.

Syntax

Read syntax diagramSkip visual syntax diagram>>-IDMMX.PredictClass--(--ModelName--,--+-InputDataAsXMLString-----+--,--return value--)-><
                                        '-InputDataAsApplRowObject-'

Parameters

ModelName
The name of a model in the default table containing Classification models
InputDataAsXMLString
A string that contains all the input arguments required by the model. The string can be produced by nested calls of IDMMX.DM_applData or assembled manually.
InputDataAsApplRowObject
An IDMTY.DM_ApplRow object containing the required input data in its IDMTY.DM_ApplColumn elements.
return value
Returns the predicted class as data type VARCHAR2

PredictClassConf

This function obtains the classification confidence value from results data that is produced when you apply a Classification model. The confidence is a value between 0.0 and 1.0 that expresses the probability that the class is predicted correctly.

Syntax

Read syntax diagramSkip visual syntax diagram>>-IDMMX.PredictClassConf--(--ModelName--,--+-InputDataAsXMLString-----+--,--return value--)-><
                                            '-InputDataAsApplRowObject-'

Parameters

ModelName
The name of a model in the default table containing Classification models
InputDataAsXMLString
A string that contains all the input arguments required by the model. The string can be produced by nested calls of IDMMX.DM_applData or assembled manually.
InputDataAsApplRowObject
An IDMTY.DM_ApplRow object containing the required input data in its IDMTY.DM_ApplColumn elements
return value
Returns the confidence value as data type NUMBER

PredictClusConf

This function obtains the confidence from results data that is produced when you apply a Clustering model. This is a value between 0.0 and 1.0 that expresses the probability that the predicted cluster is the best match against the other clusters.

Syntax

Read syntax diagramSkip visual syntax diagram>>-IDMMX.PredictClusConf--(--ModelName--,--+-InputDataAsXMLString-----+--,--return value--)-><
                                           '-InputDataAsApplRowObject-'

Parameters

ModelName
The name of a model in the default table containing Clustering models
InputDataAsXMLString
A string that contains all the input arguments required by the model. The string can be produced by nested calls of IDMMX.DM_applData or assembled manually.
InputDataAsApplRowObject
An IDMTY.DM_ApplRow object containing the required input data in its IDMTY.DM_ApplColumn elements
return value
Returns the Clustering quality as data type NUMBER

PredictClusterID

This function obtains the cluster ID from results data that is produced when you apply a Clustering model. It identifies the particular cluster in the Clustering model that is the best match for this data.

Syntax

Read syntax diagramSkip visual syntax diagram>>-IDMMX.PredictClusterID--(--ModelName--,--+-InputDataAsXMLString-----+--,--return value--)-><
                                            '-InputDataAsApplRowObject-'

Parameters

ModelName
The name of a model in the default table containing Clustering models
InputDataAsXMLString
A string that contains all the input arguments required by the model. The string can be produced by nested calls of IDMMX.DM_applData or assembled manually.
InputDataAsApplRowObject
An IDMTY.DM_ApplRow object containing the required input data in its IDMTY.DM_ApplColumn elements
return value
Returns the cluster ID as data type NUMBER

PredictClusQuality

This function returns the quality of the result for a given cluster. It measures how good the applied record fits into the given cluster. The returned value is between 0.0 and 1.0. A value close to 0.0 means that the record does not fit at all into the cluster, a value close to 1.0 means that the record fits very well in the given cluster. The quality measurement depends on the algorithm used to score the record, so that a direct comparison between the quality of both clustering algorithm results is not possible. However, both algorithms use a linear, possibly similar quality measurement function.

Syntax

Read syntax diagramSkip visual syntax diagram>>-IDMMX.PredictClusQuality--(--ModelName--,--+-InputDataAsXMLString-----+--,--return value--)-><
                                              '-InputDataAsApplRowObject-'

Parameters

ModelName
The name of a model in the default table containing Clustering models
InputDataAsXMLString
A string that contains all the input arguments required by the model. The string can be produced by nested calls of IDMMX.DM_applData or assembled manually.
InputDataAsApplRowObject
An IDMTY.DM_ApplRow object containing the required input data in its IDMTY.DM_ApplColumn elements
return value
Returns the Clustering quality as data type NUMBER

PredictClusScore

This function obtains the Clustering quality from results data that is produced when you apply a Clustering model. The score is an expression of how closely the data matches the predicted cluster. For Distribution-based Clustering a score value close to 1.0 indicates a good match. For Center-based Clustering a score value close to 0.0 indicates a good match.

Note:
The score value may indicate a good match even if the confidence returned by PredictClusConf is low. This happens if the data matches another cluster that is very close to the first one.

Syntax

Read syntax diagramSkip visual syntax diagram>>-IDMMX.PredictClusScore--(--ModelName--,--+-InputDataAsXMLString-----+--,--return value--)-><
                                            '-InputDataAsApplRowObject-'

Parameters

ModelName
The name of a model in the default table containing Clustering models
InputDataAsXMLString
A string that contains all the input arguments required by the model. The string can be produced by nested calls of IDMMX.DM_applData or assembled manually.
InputDataAsApplRowObject
An IDMTY.DM_ApplRow object containing the required input data in its IDMTY.DM_ApplColumn elements
return value
Returns the Clustering quality as data type NUMBER

PredictValue

This function obtains the predicted value from results data that is produced when you apply a Regression model. This value is calculated according to relations that are established by the model.

Syntax

Read syntax diagramSkip visual syntax diagram>>-IDMMX.PredictValue--(--ModelName--,--+-InputDataAsXMLString-----+--,--return value--)-><
                                        '-InputDataAsApplRowObject-'

Parameters

ModelName
The name of a model in the default table containing Regression models
InputDataAsXMLString
A string that contains all the input arguments required by the model. The string can be produced by nested calls of IDMMX.DM_applData or assembled manually.
InputDataAsApplRowObject
An IDMTY.DM_ApplRow object containing the required input data in its IDMTY.DM_ApplColumn elements
return value
Returns the predicted value as data type NUMBER

IM Scoring utilities reference

This chapter contains full descriptions of all the utilities provided with IM Scoring. They are presented in alphabetical order of the utility names. Data types reference shows which data types are used by functions.

For instructions on how to use the database objects presented here, see Using IM Scoring.

For instructions on how to read the syntax diagrams, see How to read the syntax diagrams.

DM_initialize

This function performs the necessary initialization for a user account to enable the application functions for this user. It must be called once for every schema that is used to execute application functions.

If you do not use this function before the first invocation of an application function, the latter displays an error message. The message requests you to call DM_initialize first.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_initialize-----------------------------------------------><

Usage

In SQL*Plus you call this function as follows:

execute IDMMX.DM_initialize

DM_memoryFree

This function clears the model cache and closes open files (the error file and optionally the trace file).

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_memoryFree-----------------------------------------------><

Usage

The function reports an error if there was no cache to be cleared and no file to be closed. You might want to call this function in the following situations:

DM_printenv

This function displays all environment variables and their values.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_printenv-------------------------------------------------><

Usage

This function uses functions of the Oracle package DBMS_OUTPUT to write its output. To display the text in SQL*Plus, you must first call the SQL*Plus command set serverout before you call the DM_printenv function.

 
set serverout on
execute IDMMX.DM_printenv

DM_printModelCache

This function displays the names of the models that are currently in the model cache. The cache holds a maximum of two models.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_printModelCache------------------------------------------><

Usage

This function uses functions of the Oracle package DBMS_OUTPUT to write its output. To display the text in SQL*Plus, you must first call the SQL*Plus command set serverout before you call the DM_printModelCache function.

set serverout on
execute IDMMX.DM_printModelCache

When you use one of the DM_applXXXModel functions to perform a scoring run, the model passed to this function must be first parsed and analyzed. This must happen before the input data records can be applied to the model. The model-parsing step can be time consuming. For this reason, the parsed model is saved in a cache to be reusable in subsequent SQL statements that use the same model. The cache can hold up to two models. The cache is cleared when the database session ends, or when the user explicitly calls DM_memoryFree. A situation might arise where a model that is not in the cache is used in a DM_applyXXXModel function and the cache is full. In this case, one of the models in the cache is replaced by the new model.

DM_setEnv

This function sets or resets environment variables for scoring functions.

Currently, this function sets or resets only the environment variables that control error handling and the tracing process. These environment variables are stored in the database; they are not visible in the environment of your operating system. These environment variables are global to all users of the scoring functions; all users share the same set of these variables. See Getting trace information for more details.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DM_setEnv--(--variable name--,--variable value--)-----------><

Parameters

variable name
The name of an environment variable for which you want to specify a value. The maximum length of the name is 32 characters.

Currently this parameter accepts only variable names that control error handling and the tracing process.

  • IDM_MX_ERRORFILE to specify the name and location of the error log
  • IDM_MX_TRACEFILE to specify the name and location of the trace log
  • IDM_MX_TRACELEVEL to control the level of trace details

See Getting trace information for details about the use of these environment variables.

variable value
The value to be specified for the named environment variable, as data type VARCHAR2(256). If you specify NULL as a value, the named variable is removed from the environment and becomes undefined.

For the IDM_MX_TRACEFILE environment variable you can specify:

  • A specific name and path for the trace log
  • NULL to reset the trace log to the default.

For the IDM_MX_TRACELEVEL environment variable you can specify:

  • One of the values MINIMUM, BASIC, MOST, or ALL

See Getting trace information for details about these variable values.

For the IDM_MX_ERRORFILE environment variable you can specify:

  • A specific name and path for the error log
  • NULL to reset the error log to the default.

In SQL*Plus you can call this function as:

 
execute IDMMX.DM_setEnv('variablename','variablevalue')

Command reference

This chapter contains full descriptions of the commands provided with IM Scoring. Use these commands to:

You can find these commands in the bin directory of your IM Scoring installation.

The idm_setup command

You must enable every database that you want to use for IM Scoring by calling the script idm_setup.

Syntax

Read syntax diagramSkip visual syntax diagram>>-idm_setup---------------------------------------------------><

Return value

To execute the script, you must be able to log in to Oracle via SQL*Plus. It performs most of its operations as user SYS, so it asks for the password of SYS in the beginning. Afterwards, it creates several database objects that implement the IM Scoring functionality. The output from the executed commands is displayed and also written to a log file, setup.log. After executing the script, enter exit to leave SQL*Plus.

The idm_setup utility creates two new schemas in the database, as follows:

If you want to prevent regular users from directly connecting to one of these schemas, you should lock the schemas.

You can change the names of some of the database objects that are created. To do this, edit the file idm_setvars.sql before you call idm_setup, but this is recommended only if there are name conflicts with existing database objects. The script idm_setup enables the default database, that is, the database you log in to without specifying an explicit database name. If you want to enable other databases, change the environment variable ORACLE_SID accordingly before you call idm_setup.

The idm_uninstall command

A database that has been enabled for IM Scoring by means of idm_setup can be disabled again by running the SQL script idm_uninstall.sql. The script removes all of the database objects that have been created by idm_setup.

Syntax

Read syntax diagramSkip visual syntax diagram>>-sqlplus "SYS--/--password--as SYSDBA" @idm_uninstall.sql----><

Usage

To use the idm_uninstall command:

  1. Log in to the database as user SYS
  2. Call the script idm_uninstall.sql as follows:
    @idm_uninstall

Before you call the command above, you must change to the bin directory of the IM Scoring installation where the script idm_uninstall.sql is located.

The script idm_uninstall disables the default database, that is, the database you log in to without specifying an explicit database name. If you want to disable other databases, change the environment variable ORACLE_SID accordingly before you call SQL*Plus.

Notes:
  1. If you need to call idm_setup more than once, it is not necessary to execute idm_uninstall before you do so.
  2. The idm_uninstall.sql command does not remove mining models that you have saved in the sample tables or in any other database tables.

The idmlevel command

Use the command idmlevel to collect information about the software environment (operating system) and IM product version you are using.

Syntax

Read syntax diagramSkip visual syntax diagram>>-idmlevel--+---------+---------------------------------------><
             '-logfile-'

Parameters

logfile
Specifies the path and name of the file into which the result of the idmlevel command is written. If you do not specify a log file, the result is displayed on the screen. This parameter is optional.

Related concepts

Getting product information

Examples

More examples are provided in:

The idmlicm command

Use the idmlicm command to check your license status. IM Scoring uses nodelocked license keys installed in a license file. The full product contains production license keys, which are installed during installation. The 'Try and Buy' version does not include a production license key. You can use the idmlicm command to generate a 'Try and Buy' license key.

Syntax

Read syntax diagramSkip visual syntax diagram>>-idmlicm-----------------------------------------------------><

Related concepts

Getting product information

Examples

The idmlicm command is located in the bin directory. It has no parameters. When invoked, idmlicm checks the license status.

Sample output with production license
The license for the product "DB2 Intelligent Miner Scoring" 
     was found in the file "nodelock_sc".

If no production license is installed, idmlicm can generate a temporary license key the first time it is invoked.

Sample output with temporary license
W 2771: You are now using a temporary license. You need 
to enroll "DB2 Intelligent Miner Scoring" within "89" days 
in the license file "d:\IMinerX\bin\nodelock_sc".

If you invoke idmlicm when a temporary license is already installed, you get the following sample output:

Sample output with temporary license already installed
W 2772: The number of days left is "89". You are still using 
a temporary license. You need to enroll "DB2 Intelligent Miner Scoring" 
in the license file "d:\IMinerX\bin\nodelock_sc".

The idmmkSQL command

The command idmmkSQL analyzes a PMML model, and generates from it a template SQL script that contains the SQL statements necessary to perform a scoring run using the model. It contains placeholders that you replace with the names of concrete database objects in order to finally get the executable SQL script.

Note:
idmmkSQL can read the PMML model from the file system, models in Oracle tables are not supported.

Syntax

Read syntax diagramSkip visual syntax diagram>>-idmmkSQL--+---------+--inputfile--+------------+------------><
             '-options-'             '-outputfile-'

Parameters

options
Specifies the following options.
Note:
You can start with a slash (/) or a hyphen (-).
-M
Identifies the method used to build input records. The option must be followed by one of the following values (not case-sensitive):
-O
Identifies the method used to build the SQL script. For Oracle, there is only one method:
TABLE
Permanently stores scoring results in a table. This is the default.
-D
Determines whether DB2 SQL or Oracle SQL is written. The option must be followed by one of the following values, which are not case-sensitive:
  • DB2 (the default value)
  • ORACLE
-E
Determines the encoding of the PMML file and SQL script. The option must be followed by a valid encoding string:
  • If this option is not given, the encoding string contained in the PMML file is used.
  • If the file does not contain encoding information, utf-8 is the default encoding.
-H
Displays help information.
inputfile
Specifies the file that contains the PMML model.
outputfile
Specifies the file to which the SQL template is written. If no outputfile is given, the template is written to standard output.

Usage notes

Placeholders
The placeholders are marked with leading and trailing ### signs, for example, ###TABLENAME###. The template contains CLUSTERMODELS by default without any placeholders.
Note:
To generate the SQL script by using idmmkSQL, you need the model as a PMML file or in a DB2 database.
###ABSOLUTE_PATH###
The absolute path to the PMML file. The function that imports the PMML model needs the absolute path name of the file.
###RECORDID###
The table containing the input data records for the scoring run is expected to have a column to identify different records. Replace ###RECORDID### with the name of the column.
###INTEGER###
Replace ###INTEGER### with the data type of the previously specified ID column.
###TABLENAME###
The name of the table containing your input data records.

If PMML files in the file system are processed, default values are used for tables in which mining models are to be stored. However, you can specify another table to store your models by replacing the following strings:

CLUSTERMODELS, CLASSIFMODELS, REGRESSIONMODELS
Replace these strings by specifying the name of the table in which your mining models are to be stored.
MODEL
The name of the column in the model table containing the model itself. In the sample tables, this name is MODEL.
MODELNAME
The name of the column in the model table containing the model name. In the sample tables, this name is MODELNAME.

Related concepts

Generating SQL statements from models

Examples

In the following example the Oracle SQL template theScriptFile.sql is generated using the PMML file thePMMLFile.pmml. The SQL template uses the CONCAT method to build the input records. The encoding of the generated SQL script is iso-8859-1:

idmmkSQL -D ORACLE -M Concat -E iso-8859-1 thePMMLFile.pmml theScriptFile.sql

More examples are provided in:

The idmxmod command

You can convert a model outside IM for Data from Intelligent Miner format to PMML 2.1 format by using the idmxmod command.

Syntax

Read syntax diagramSkip visual syntax diagram>>-idmxmod--in file name--out file name------------------------><

Parameters

in file name
The name of a file containing a model in Intelligent Miner format
out file name
The name of the file containing the converted PMML model

Related concepts

Converting exported models

Administration

Getting error information
Getting support
Problem identification worksheet
Getting product information
Getting trace information
Tracing errors
Migrating from IM Scoring V7.1
Working with IM Scoring V7.1 and V8.2 in parallel
Exporting and importing models with the use of compression
Applying Neural models
Using the function DM_getClusterID
Migrating from IM Scoring Version 8.1

Getting error information

If an error occurs during a scoring run, an error message is displayed.

See DB2 Intelligent Miner Modeling, DB2 Intelligent Miner Scoring: Messages for a list of error messages with explanations of their meanings, and indications about what action you should take.

Errors are logged by default in the file idmMxError.log together with identifiers and time stamps.

When the file gets too large, you must delete it.

You can change the error file name and directory by setting the environment variable IDM_MX_ERRORFILE to the name of an alternative error file. The file name must be given as an absolute path name. The environment variable can be set by means of the function DM_setEnv. To do this, call SQL*Plus and connect to the database. Use any existing user name. Then use the following commands as required. Note that strings are case-sensitive.

Getting support

Before you contact IBM for support, check the information in the release.txt file that comes with the product. It can be found in the installation directory.

To find the latest information about IM Scoring access the Intelligent Miner Web site.

When you contact IBM for support, prepare to answer the questions in the problem identification worksheet. Make yourself familiar with the instructions on how to collect trace information given at Getting trace information.

Problem identification worksheet

The IBM Software Support Guide contains the following problem identification worksheet.

Answer the questions in the worksheet before contacting IBM support.

 
              PROBLEM IDENTIFICATION WORKSHEET
 
Complete this form before calling Technical Support
 
This form helps you identify problems and assists IBM Technical Support in
finding solutions.

System Information

What is the failing product? _______________________________________________

What is the version and release number?_____________________________________

What machine model, operating system, and version are running?______________

Problem Description

What are the expected results?______________________________________________

What statement or command is being used? ___________________________________

What are the exact symptoms and syntax? ____________________________________
____________________________________________________________________________

What is or isn't happening, including exact error number and message text? 

____________________________________________________________________________

____________________________________________________________________________

Is anyone else experiencing the problem? ___________________________________

Is this the first time this operation has been attempted? __________________

Is this the first time this problem has occurred?___________________________

Environment

When did this activity work last? __________________________________________

What has changed since the activity last worked? ___________________________

_____ Hardware type/model         _____ Application

_____ Operating system/version    _____ Level of usage

_____ New product version/release _____ Maintenance applied

If the problem does not occur every time, under what conditions does the
problem not occur?

____________________________________________________________________________

____________________________________________________________________________

Is there any other software running on the system which may be conflicting 
with this product?

____________________________________________________________________________

____________________________________________________________________________

Problem Isolation

Identify the specific feature of the software causing the problem.__________

____________________________________________________________________________

Can the problem be reproduced? If so, please provide a reproducible test case
or instructions on how to reproduce the error condition.____________________

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________
 

Getting product information

Use the command idmlevel to collect information about the software environment (operating system, version) and IM product version you are using.

For more information on using this command on Windows or UNIX operating systems refer to The idmlevel command.

Note:
Attach the resulting log file to your problem description when you contact IBM support.

Getting trace information

The trace facility in IM Scoring helps IBM to locate an error by writing information about an error situation to a file. This information consists of trace messages.

The trace facility is configured by means of two environment variables. These are as follows:

IDM_MX_TRACELEVEL determines the filtering of trace messages. IDM_MX_TRACELEVEL is effectively an on/off switch for tracing.

Since trace messages are controlled by means of environment variables, concurrent mining runs write to the same trace file.

The trace message that is written to the trace file consists of the following information:

The basic system information is written once per trace.

You can configure tracing by using special commands in your SQL*Plus session. To issue these commands, call SQL*Plus and connect to the database. Use any existing user name. Then use the following commands as required. Note that strings are case sensitive.

Changes to the variables IDM_MX_TRACEFILE and IDM_MX_TRACELEVEL become immediately effective. Scoring function calls following a change consider the new values. In addition, changes to these variables are global to all users of the scoring services. A change affects other users and is visible to other users.

Tracing errors

Use the DM_setEnv method to trace errors:

  1. Start tracing:
    execute IDMMX.DM_setEnv('IDM_MX_TRACELEVEL','ALL') 
  2. Run the function in error.
  3. Reset tracing:
    execute IDMMX.DM_setEnv('IDM_MX_TRACELEVEL','')
  4. Send the trace file to your IBM support team.
Note:
You can set the environment variable as described in Getting error information.

Migrating from IM Scoring V7.1

If you want to migrate from IM Scoring V7.1 to IM Scoring V8.2, in general you can start working with IM Scoring V8.2 after performing the following steps:

  1. Installing IM Scoring V8.2
  2. Performing the configuration steps
  3. Re-enabling your databases or enabling new databases
    Note:
    You need not disable your databases before you re-enable them.

Working with IM Scoring V7.1 and V8.2 in parallel

Windows platform:
You cannot work with both versions on one machine on the Windows platform. If you install IM Scoring V8.2 on a Windows machine and the installation finds IM Scoring V7.1, IM Scoring V7.1 is automatically uninstalled.
UNIX platforms:
IM Scoring V8.2 installs into a directory that is different from the one used for IM Scoring V7.1. This means that you can have both versions installed on one machine. However, it is recommended that you migrate to IM Scoring V8.2, because there is a high risk of user error if you use both versions.

However, you must use a different database for each product, because you can enable a database for only one product at the same time.

Exporting and importing models with the use of compression

IM Scoring V8.2 stores models in a compressed format in a database, however, it can also work with the uncompressed format that was used for IM Scoring V7.1.

However, if you want to save disk space, you can simply compress the models by using the export and import UDFs that are provided. These UDFs are:

 DM_expClasModel     DM_impClasModel
 
 DM_expClusModel     DM_impClusModel
 
 DM_expRegModel      DM_impRegModel

You can also compress the models by using a sample script, which is available in the directory samples/ScoringOracle. You can directly use the sample if your models are stored in the tables that are provided. These tables are as follows:

If you use tables that are different from these, you must adapt the sample to your needs before you execute it.

To execute the sample:

  1. Change to the sample/ScoringOracle directory
  2. Call SQL*Plus
  3. Enter @compressV7Models

Applying Neural models

Center-based Clustering models, Neural Classification models, and Neural Regression models that were imported by IM Scoring V7.1 can no longer be applied by IM Scoring V8.2.

If the models are still available as results in IM for Data, drop them from your tables, and import them again.

Using the function DM_getClusterID

If you use the function DM_getClusterID on a DM_ClusResult value that was returned when a Clustering model was applied, the values will differ from those returned by IM Scoring:

To get the mapping between cluster IDs and cluster names, use the DM_getClusters function on the Clustering model.

Note:
The cluster names and cluster IDs are also shown in the IM Visualizer.

Migrating from IM Scoring Version 8.1

If you want to migrate from IM Scoring V8.1 to IM Scoring V8.2, in general you can start working with IM Scoring V8.2 after performing the following steps:

  1. Installing IM Scoring V8.2
  2. Performing the configuration steps
  3. Re-enabling your databases or enabling new databases
    Note:
    When you re-enable your databases, you do not need to have already disabled any databases.

Appendixes

Appendix A. IM Scoring conformance to PMML

PMML is a markup language for data mining. Based on XML, PMML provides a standard that enables data mining models to be shared between the applications of different vendors. It provides a vendor-independent method of defining models. It allows you to exchange models between applications.

Note:
IM Scoring supports PMML up to V2.1. The term PMML, throughout this book, refers to PMML V2.1 and any previous versions of PMML, unless otherwise specified.

You can find more information about PMML on the Web site of the Data Mining Group (DMG).

Here you find information on how IM Scoring conforms to the PMML standard. The following naming conventions of the PMML standard are used:

IM Scoring application

IM Scoring provides an SQL interface enabling the application of PMML models to data.

For this feature, IM Scoring complies with the PMML consumer conformance clause of the PMML standard for several algorithms. These algorithms are listed below with possible restrictions for their consumer conformance to PMML.

Center-based clustering
Decision trees
Distribution-based clustering
Neural networks
Regression
IM Scoring supports all core and non-core features of PMML for regression.

IM Scoring conversion tools

IM Scoring delivers conversion tools that enable models in IM for Data format to be converted to PMML.

IM Scoring conversion tools comply with the PMML producer conformance clause of the PMML standard for center-based clustering, decision trees, neural networks, and regression.

IM Scoring conversion tools also comply with the PMML producer conformance clause of the PMML standard for distribution-based clustering when value weighting was not used to create the model. (For information, see the documentation for IM for Data.) However, if value weighting was used, IM Scoring conversion tools produce non-conforming PMML models with a specific extension for value weighting. This extension can be read only by IM Scoring, which will use value weighting when scoring data on these models. Other PMML consumer tools, however, will ignore the extension, though they will read the model successfully. They will not consider value weighting when scoring data on these models.

IM Scoring conversion tools additionally comply with the PMML producer conformance clause of the PMML standard for association rules. However, taxonomies and name mappings that might have been used to create the models are not written into PMML 2.1.

Regression models

IM Scoring supports Radial-Basis Function (RBF) prediction and Transform Regression. However, RBF prediction and Transform Regression are not yet part of PMML, and therefore cannot comply with the producer or consumer conformance clause. The RBF prediction models or the Transform Regression models written by IM Scoring conversion tools and used in the IM Scoring application have an XML proprietary format that is very similar to the other PMML formats.

Refer to Table 3 for an overview of all algorithms that are supported.

Features supported in addition to PMML 2.1

The following features are supported in addition to PMML 2.1 for interoperability reasons:

Appendix B. SAS Enterprise Miner support

Models generated by SAS Enterprise Miner V5.1 (abbreviated to SAS EM in this book) can be used with IM Scoring. The following algorithms are supported: Tree (PROC ARBOR), Regression (PROC DMREG), center-based Clustering (PROC DMVQ), and Neural Networks (PROC NEURAL). You do not need any special options for these models.

Notes:
  1. IM Scoring supports SAS Enterprise Miner V5.1.
  2. The following SAS EM options are not supported:

For more information refer to the SAS Enterprise Miner V5.1 documentation.

Appendix C. SPSS Clementine support

SPSS Clementine V8.5 offers a compatibility mode for generating PMML that can be used with IM Scoring. To activate this option in SPSS Clementine, from the Tools menu select User Options... and set the options as shown in Figure 7.

Note:
Models created in SPSS Clementine V8.5 can be used with IM Scoring via the PMML mechanism. However, you have to make sure that the respective options are set accordingly.
Figure 7. User options
User options

If you have set the user options as shown in Figure 7, the models exported from SPSS Clementine as PMML can be imported into IM Scoring.

The following algorithms are supported:

Notes:
  1. In accordance with the PMML standard, IM Scoring cannot distinguish arbitrary numbers of trailing blanks in values of categorical variables. Problems might arise if a field has two or more values that only differ from each other in the number of trailing blanks. SPSS Clementine prevents the export of such models or informs you that problems may occur.
  2. SPSS Clementine only scans the first few lines of a text file to determine the data type. If a numeric field has integers in the first few lines, but floating point decimals later on, SPSS Clementine might set the type to integer, even if floating point decimal is the correct type. SPSS Clementine converts these by cutting off the decimal places, while IM Scoring uses the float "as is". They produce different results.

    To solve this problem rebuild the model, either by scanning the whole dataset in SPSS Clementine or by specifying the correct data type of the respective field manually. This can also happen if the training set only consists of integers, but the floating point decimals are inserted during application.

  3. SPSS Clementine Neural Networks and Tree C5 models trained to predict an integer column return a floating point decimal if applied in IM Scoring. If the result is inserted into a column of type integer, it must be explicitly converted to integer via the scalar SQL function ROUND. Otherwise the decimal places will be cut off, leading to different results.

For more information refer to the SPSS Clementine V8.5 documentation.

Appendix D. Using IM Scoring in a multilanguage environment

When you create an Oracle database, you must specify the database character set. See the release.txt file for the latest information about which of the Oracle character sets can be used together with IM Scoring.

You might want to create a new database in a multilanguage environment and enable this database for the scoring functions. In this case, it is recommended that you create this database using the Unicode character encoding. In a Unicode-enabled database, Oracle supports the following character encoding scheme: UTF-8, that is, the UCS (Universal Character Set) Transformation Format.

Appendix E. Encoding considerations when exporting models

If one of the following PMML models are exported by using the IM Scoring export functions, the XML declaration in the PMML model contains an encoding specification:

For some operation systems and locale combinations, for example, Japanese on AIX, the encoding name used is specific to the International components for Unicode.

For example, for Japanese models generated on AIX, the XML declaration might look like this:

<?xml version="1.0" encoding="ibm-942_P120_2000" ?>
<PMML version="2.1">

When you exchange these models as a file with other products that can read the PMML format, these products might not support these encoding names.

You can solve the problem by manually editing the PMML model and changing the encoding name to a compatible name supported by your product.

For example:

<?xml version="1.0" encoding="ibm-942" ?>
<PMML version="2.1">

Appendix F. Notices

IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service.

IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not give you any license to these patents. You can send license inquiries, in writing, to:

IBM Director of Licensing
IBM Corporation
North Castle Drive
Armonk, NY 10504-1785
U.S.A.

For license inquiries regarding double-byte (DBCS) information, contact the IBM Intellectual Property Department in your country or send inquiries, in writing, to:

IBM World Trade Asia Corporation
Licensing
2-31 Roppongi 3-chome, Minato-ku
Tokyo 106, Japan

The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you.

This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice.

Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk.

IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you.

Licensees of this program who wish to have information about it for the purpose of enabling: (i) the exchange of information between independently created programs and other programs (including this one) and (ii) the mutual use of the information which has been exchanged, should contact:

IBM  Deutschland GmbH
Department  0790
Pascalstrasse 100
70569 Stuttgart  
Germany

Such information may be available, subject to appropriate terms and conditions, including in some cases, payment of a fee.

The licensed program described in this information and all licensed material available for it are provided by IBM under terms of the IBM Customer Agreement or any equivalent agreement between us.

Any performance data contained herein was determined in a controlled environment. Therefore, the results obtained in other operating environments may vary significantly. Some measurements may have been made on development-level systems and there is no guarantee that these measurements will be the same on generally available systems. Furthermore, some measurement may have been estimated through extrapolation. Actual results may vary. Users of this document should verify the applicable data for their specific environment.

Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.

All statements regarding IBM's future direction or intent are subject to change or withdrawal without notice, and represent goals and objectives only.

This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental.

COPYRIGHT LICENSE:

This information contains sample application programs in source language, which illustrates programming techniques on various operating platforms. You may copy, modify, and distribute these sample programs in any form without payment to IBM, for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

You may copy, modify, and distribute these sample programs in any form without payment to IBM for the purposes of developing, using, marketing, or distributing application programs conforming to IBM's application programming interfaces.

Each copy or any portion of these sample programs or any derivative work, must include a copyright notice as follows:

(C) (your company name) (year). Portions of this code are derived from IBM Corp. Sample Programs. (C) Copyright IBM Corp. _enter the year or years_. All rights reserved.

Trademarks

The following terms are trademarks of the IBM Corporation in the United States, other countries, or both:

alphaWorks
AIX
DB2
DB2 Universal Database
IBM
Intelligent Miner
Redbooks
WebSphere

UNIX is a registered trademark of The Open Group in the United States and other countries.

Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both.

Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.

Other company, product, and service names may be trademarks or service marks of others.

Bibliography

This bibliography lists all publications in the Intelligent Miner library other than this book, related IBM or Oracle publications that are relevant to the contents of this book, and non-IBM publications that might be useful for reference purposes.

IBM DB2 Intelligent Miner publications

Oracle publications

Related information

IBM Web sites

Other Web sites

Index

Special characters
A B C D E F G I J L M N O P Q R S T U W X
Special characters A B C D E F G I J L M N O P Q R S T U W X