Oracle® Database SQL Reference 10g Release 2 (10.2) Part Number B14200-02 |
|
|
View PDF |
Syntax
cost_matrix_clause::=
mining_attribute_clause::=
Purpose
This function is for use with models created by the DBMS_DATA_MINING
package or with the Oracle Data Mining Java API. It returns the best prediction for the model. The datatype returned depends on the target value type used during the build of the model. For regression models, this function returns the expected value.
COST MODEL Specify COST
MODEL
to indicate that the scoring should be performed by taking into account the cost matrix that was associated with the model at build time. If no such cost matrix exists, then the database returns an error. The COST
MODEL
clause is relevant only for decision tree classification models.
If you omit the COST
MODEL
clause, the best prediction is the target class with the highest probability. If two or more classes are tied with the highest probability, the database chooses one class.
mining_attribute_clause This maps the predictors that were provided when the model was built. Specifying USING *
maps to all to the columns and expressions that can be retrieved from the underlying inputs (tables, views, and so on).
If you specify more predictors in the mining_attribute_clause
than there are predictors used by the model, then the extra expressions are silently ignored.
If you specify fewer predictors than are used during the build, then the operation proceeds with the subset of predictors you specify and returns information on a best-effort basis. All types of models will return a result regardless of the number of predictors you specify in this clause.
If you specify a predictor with the same name as was used during the build but a different datatype, then the database implicitly converts to produce a predictor value of the same type as the original build.
See Also:
Oracle Data Mining Concepts for detailed information on Oracle Data Mining features
Oracle Data Mining Administrator's Guide for information on the demo programs available in the code
Oracle Data Mining Application Developer's Guide for information on writing Oracle Data Mining applications
Example
The following example returns by gender the average age of customers who are likely to use an affinity card. The PREDICTION
function takes into account only the cust_marital_status
, education
, and household_size
predictors.
This example, and the prerequisite data mining operations, including the creation of the view, can be found in the demo file $ORACLE_HOME/rdbms/demo/dmdtdemo.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.
SELECT cust_gender, COUNT(*) AS cnt, ROUND(AVG(age)) AS avg_age FROM mining_data_apply_v WHERE PREDICTION(DT_SH_Clas_sample COST MODEL USING cust_marital_status, education, household_size) = 1 GROUP BY cust_gender ORDER BY cust_gender; C CNT AVG_AGE - ---------- ---------- F 170 38 M 685 42