Predictive Analytics Snippets

To view the list of Predictive Analytics functions, and to use a snippet:

  1. Open Oracle SQL Developer.

  2. Select the connection that you are using for Oracle Data Miner.

  3. From the SQL Developer menu, go to View and then select Snippets.

  4. From the drop-down list, select Predictive Analytics.

    The Predictive Analytics group of snippets includes the following snippets:

    • Explain: Use DBMS_PREDICTIVE_ANALYTICS.EXPLAIN() to rank attributes in order of influence when explaining a target column.

    • Predict: Use DBMS_PREDICTIVE_ANALYTICS.PREDICT() to predict the value of a target column based on values in the input data.

    • Prediction Anomaly Function: Use the anomaly detection predictive query to predict the anomalous customers.

    • Prediction Classification Function: Makes predictions using dynamic classifications.

    • Prediction Cluster Function: Predicts the cluster a customer belongs to.

    • Prediction Feature Set Function: Predicts feature sets to provide a general characterization of the underlying customer data.

    • Prediction Regression Function: Predicts the age of customers who are likely to use an affinity card.

    • Profile: Use DBMS_PREDICTIVE_ANALYTICS.PROFILE() to generate rules that identify the records that have the same target value.

  5. To use a snippet, drag the snippet to the SQL Worksheet or to a place in a PL/SQL program.


    Note:

    The Explain, Predict, and Profile snippets have one or more commented-out DROP statements, such as:

    --DROP TABLE mining_explain_result;

    If you run one of these snippets more than once, remove the comment characters for the DROP statement.


If you drag the Explain snippet to SQL Worksheet, you see:

--Available in Oracle Enterprise DB 10.2 and later

--Ranks attributes in order of influence to explain a target column.

--For more info go to: http://www.oracle.com/pls/db112/vbook_subject?subject=dma

--Remove comment on the Drop statement if you want to rerun this script

--DROP TABLE mining_explain_result;

--Perform EXPLAIN operation

BEGIN

DBMS_PREDICTIVE_ANALYTICS.EXPLAIN(

data_table_name => '"CUSTOMERS"',

explain_column_name => '"CUST_GENDER"',

result_table_name => 'mining_explain_result',

data_schema_name => '"SH"');

END;

/

--output first 10 rows from resulting table mining_explain_result

COLUMN ATTRIBUTE_NAME FORMAT A30

COLUMN ATTRIBUTE_SUBNAME FORMAT A30

COLUMN EXPLANATORY_VALUE FORMAT 0D999999

COLUMN RANK FORMAT 999999

select * from mining_explain_result where rownum < 10;

When you run this code, you get the following results (in Script Output):

anonymous block completed

ATTRIBUTE_NAME ATTRIBUTE_SUBNAME EXPLANATORY_VALUE RANK

----------------- ------------------------------ ----------------- ------

CUST_LAST_NAME 0.151359 1

CUST_MARITAL_STATUS 0.015043 3

CUST_INCOME_LEVEL 0.002592 4

CUST_CREDIT_LIMIT 0.000195 5

CUST_EMAIL 0.000000 6

CUST_TOTAL 0.000000 6

CUST_TOTAL_ID 0.000000 6

CUST_FIRST_NAME 0.000000 6

9 rows selected


See Also: