SQL/MX Data Mining Guide

Mining the Data
HP NonStop SQL/MX Data Mining Guide523737-001
4-10
Applying the Model to the Mining Table
Applying the Model to the Mining Table
You must check your model against the mining table.
Finding the Rows Where the Customer Left
This query finds most of the rows where Cust_Left is equal to Y:
SELECT account, cust_left FROM miningview
WHERE (marital_status = 'Divorced' AND gender = 'M')
OR (marital_status = 'Single' AND number_children = 0);
Account Number CUST_LEFT
-------------- ---------
1234567 Y
2300000 Y
2500000 Y
3200000 Y
3900000 Y
4098124 Y
4400000 Y
4600000 Y
--- 8 row(s) selected.
Applying the Model to the Database
Now, check your model against the database. Before applying the model to the
database, you can remove the tables and attributes that are not used in the analysis.
You must remove any mappings you created between the values in the database and
the values in the mining table.
Deploying the Model
After a model has been built and tested, the results are deployed into the business
environment. In many cases, deployment means exporting the model back to the
database to be used to evaluate new cases. Depending on its complexity, a model can
be evaluated directly in the database by using standard SQL or user-defined functions.
Simple models like decision trees can usually be represented in standard SQL by
using a complex CASE statement. Many mining tools have the ability to export a CASE
statement representing a decision tree.
However, many times, models cannot be evaluated directly by using SQL. In this case,
user-defined functions are needed. Most mining tools have the ability to export a C
function that evaluates a model. The function code can be compiled and then executed
in the DBMS as a user-defined function. Object relational enhancements to SQL/MX
include such user-defined functions, which are accessible through standard SQL and
executed directly in the database.