Skip Headers
Oracle® Database SQL Language Reference
11g Release 2 (11.2)

Part Number E26088-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

CLUSTER_SET

Syntax

Description of cluster_set.gif follows
Description of the illustration cluster_set.gif

mining_attribute_clause::=

Description of mining_attribute_clause.gif follows
Description of the illustration mining_attribute_clause.gif

Purpose

This function is for use with clustering models created by the DBMS_DATA_MINING package or with Oracle Data Miner. It returns a varray of objects containing all possible clusters that a given row belongs to. Each object in the varray is a pair of scalar values containing the cluster ID and the cluster probability. The object fields are named CLUSTER_ID and PROBABILITY, and both are Oracle NUMBER.

You can specify topN and cutoff together to restrict the returned clusters to those that are in the top N and have a probability that passes the threshold.

The mining_attribute_clause behaves as described for the PREDICTION function. Refer to mining_attribute_clause.

See Also:

Examples

The following example lists the most relevant attributes (with confidence > 55%) of each cluster to which customer 101362 belongs with > 20% likelihood.

This example, and the prerequisite data mining operations, including the creation of the km_sh_clus_sample model and the views and type, can be found in the demo file $ORACLE_HOME/rdbms/demo/dmkmdemo.sql. General information on data mining demo files is available in Oracle Data Mining Administrator's Guide. The example is presented here to illustrate the syntactic use of the function.

WITH
clus_tab AS (
SELECT id,
       A.attribute_name aname,
       A.conditional_operator op,
       NVL(A.attribute_str_value,
         ROUND(A.attribute_num_value),4)) val,
       A.attribute_support support,
       A.attribute_confidence confidence
  FROM TABLE(DBMS_DATA_MINING.GET_MODEL_DETAILS_KM('km_sh_clus_sample')) T,
       TABLE(T.rule.antecedent) A
 WHERE A.attribute_confidence > 0.55
),
clust AS (
SELECT id,
       CAST(COLLECT(Cattr(aname, op, TO_CHAR(val), support, confidence))
         AS Cattrs) cl_attrs
  FROM clus_tab
GROUP BY id
),
custclus AS (
SELECT T.cust_id, S.cluster_id, S.probability
  FROM (SELECT cust_id, CLUSTER_SET(km_sh_clus_sample, NULL, 0.2 USING *) pset
          FROM mining_data_apply_v
         WHERE cust_id = 101362) T,
       TABLE(T.pset) S
)
SELECT A.probability prob, A.cluster_id cl_id,
       B.attr, B.op, B.val, B.supp, B.conf
  FROM custclus A,
       (SELECT T.id, C.*
          FROM clust T,
               TABLE(T.cl_attrs) C) B
 WHERE A.cluster_id = B.id
ORDER BY prob DESC, cl_id ASC, conf DESC, attr ASC, val ASC;

   PROB      CL_ID ATTR                       OP VAL             SUPP    CONF
------- ---------- -------------------------- -- ----------- -------- -------
  .7745          8 HOUSEHOLD_SIZE             IN 9+               124   .7500
  .7745          8 CUST_MARITAL_STATUS        IN Divorc.          116   .6000
  .7745          8 CUST_MARITAL_STATUS        IN NeverM           116   .6000
  .7745          8 CUST_MARITAL_STATUS        IN Separ.           116   .6000
  .7745          8 CUST_MARITAL_STATUS        IN Widowed          116   .6000
  .2028          6 AGE                        >= 17               154   .6667
  .2028          6 AGE                        <= 31.6             154   .6667
  .2028          6 CUST_MARITAL_STATUS        IN NeverM           172   .6667
8 rows selected.