text:
,��Foa�, mimetypeapplication/epub+zipPK ,��F OEBPS/content.opf��
This chapter shows how you can perform complex data mining operations by using simple SQL queries and PL/SQL procedures. The examples show techniques for obtaining valuable information about your customers. This kind of information is needed to answer business questions, such as: How should we position a product? When should we introduce a new product? What pricing and sales promotion strategies should we use?
Note:The base interfaces to Oracle Data Mining are PL/SQL packages and SQL functions. Most of the examples throughout this manual use PL/SQL and SQL code.
Oracle Data Mining also supports a standards-based Java API, which is layered on the SQL API. The Java API is described in "Data Mining Java API" and in Chapter 7.
See Also:
This chapter contains the following topics:
The code fragments in this section show how you can apply data mining models to learn more about your customers.
These examples use models that were previously created. They exist in Oracle Database as database objects. For the sake of simplicity, we can assume that you created the models, that they exist within your schema, and that you are executing the SQL statements that apply them. You could have used the PL/SQL API or the Java API to create the models.
See Also:Chapter 5, "Building a Model"
The primary method for applying data mining models is by executing specialized SQL functions. There exists a separate family of SQL functions for prediction, clustering, and feature extraction.
Note:The examples in the first two sections of this chapter illustrate SQL syntax for different use cases, but the code uses hypothetical object names. For example, a table might be named
The query in Example 1-1 divides customers into segments and predicts customer attrition.
The segments are created by a clustering model named
clus_model. The model uses heuristics to divide the customer database into groups that have similar characteristics.The prediction is generated by a classification model called
The model predicts the attrition probability for each customer in each segment. The data is returned by segment, ordered by the overall attrition propensity in the segment.
Example 1-1 Predict Attrition for Customer Segments
SELECT count(*) as cnt, AVG(
svmC_model, 'attrite' USING *)) as avg_attrite, AVG(cust_value_score) FROM customers GROUP BY
clus_modelUSING *) ORDER BY avg_attrite DESC;
The sophisticated analytics within this seemingly simple query let you see your customer base within natural groupings based on similarities. The SQL data mining functions show you where your most loyal and least loyal customers are. This information can help you make decisions about how to sell your product. For example, if most of the customers in one segment have a high probability to attrite, you might take a closer look at the demographics of that segment when considering your marketing strategy.
CLUSTER_ID function in Example 1-1 applies the mining model
clus_model to the
customers table. It returns the segment for each customer. The number of segments is determined by the clustering algorithm. Oracle Data Mining supports two clustering algorithms: enhanced k-Means and O-Cluster.
PREDICTION_PROBABILITY function in Example 1-1 applies the mining model
svmC_model and returns the probability to attrite for each customer. Oracle Data Mining supports a number of classification algorithms. In this case, the model name implies that Support Vector Machine was chosen as the classifier.
The sample query in Example 1-2 returns the ten customers who are most likely to attrite, based on
annual_income, and
In addition, since
annual_income is often missing, the
PREDICTION function is used to perform missing value imputation for the
annual_income attribute. The
PREDICTION function applies the regression model,
svmR_model, to predict the most likely annual income. The
NVL function replaces missing annual income values with the resulting prediction.
Example 1-2 Predict Customer Attrition and Transform Missing Income Values
SELECT * FROM ( SELECT cust_name, cust_contact_info FROM customers ORDER BY
tree_model, 'attrite' USING age, gender, zipcode, NVL(annual_income,
svmR_modelUSING *)) as annual_income) DESC) WHERE rownum < 11;
These examples use a one-class SVM model to discover atypical customers (outliers), find common demographic characteristics of the most typical customers, and compute the probability that a new or hypothetical customer will be a typical affinity card holder.
Find the top 10 outliers -- customers that differ the most from the rest of the population. Depending on the application, such atypical customers can be removed from the data.
SELECT cust_id FROM ( SELECT cust_id FROM svmo_sh_sample_prepared ORDER BY
SVMO_SH_Clas_sample, 0 using *) DESC, 1) WHERE rownum < 11;
Compute the probability of a new or hypothetical customer being a typical affinity card holder. Normalization of the numerical attributes is performed on-the-fly.
WITH age_norm AS ( SELECT shift, scale FROM SVMO_SH_sample_norm WHERE col = 'AGE'), yrs_residence_norm AS ( SELECT shift, scale FROM svmo_sh_sample_norm WHERE col = 'YRS_RESIDENCE') SELECT
SVMO_SH_Clas_sample, 1 using (44 - a.shift)/a.scale AS age, (6 - b.shift)/b.scale AS yrs_residence, 'Bach.' AS education, 'Married' AS cust_marital_status, 'Exec.' AS occupation, 'United States of America' AS country_name, 'M' AS cust_gender, 'L: 300,000 and above' AS cust_income_level, '3' AS houshold_size ) prob_typical FROM age_norm a, yrs_residence_norm b;
Find demographic characteristics of the typical affinity card members. These statistics will not be influenced by outliers and are likely to provide a more truthful picture of the population of interest than statistics computed on the entire group of affinity members.
SELECT a.cust_gender, round(avg(a.age)) age, round(avg(a.yrs_residence)) yrs_residence, count(*) cnt FROM mining_data_one_class_v a WHERE
SVMO_SH_Clas_sampleusing *) = 1 GROUP BY a.cust_gender ORDER BY a.cust_gender;
This example uses a classification model to predict who will respond to a marketing campaign for DVDs and why.
First predict the responders.
This statement uses the
PREDICTION and
PREDICTION_DETAILS functions to apply the model
SELECT cust_name,
PREDICTION(campaign_model USING *)
AS responder,
PREDICTION_DETAILS(campaign_model USING *)
AS reasonFROM customers;
Combine the predictions with relational data.
This statement combines the predicted responders with additional information from the
sales table. In addition to predicting the responders, it shows how much each customer has spent for a period of three months before and after the start of the campaign.
SELECT cust_name, PREDICTION(campaign_model USING *) AS responder,
SUM(CASE WHEN purchase_date < 15-Apr-2005 THEN
purchase_amt ELSE 0 END) AS pre_purch,
SUM(CASE WHEN purchase_date >= 15-Apr-2005 THEN
purchase_amt ELSE 0 END) AS post_purchFROM customers,
salesWHERE sales.cust_id = customers.cust_id AND
purchase_date BETWEEN 15-Jan-2005 AND 14-Jul-2005GROUP BY cust_id, PREDICTION(campaign_model USING *);
Combine the predictions and relational data with multi-domain, multi-database data.
In addition to predicting responders, find out how much each customer has spent on DVDs for a period of three months before and after the start of the campaign.
SELECT cust_name, PREDICTION(campaign_model USING *) as responder, SUM(CASE WHEN purchase_date < 15-Apr-2005 THEN purchase_amt ELSE 0 END) AS pre_purch, SUM(CASE WHEN purchase_date >= 15-Apr-2005 THEN purchase_amt ELSE 0 END) AS post_purch FROM customers, sales,
products@PRODDBWHERE sales.cust_id = customers.cust_id AND purchase_date BETWEEN 15-Jan-2005 AND 14-Jul-2005 AND sales.prod_id = products.prod_id
AND CONTAINS(prod_description, 'DVD') > 0GROUP BY cust_id, PREDICTION(campaign_model USING *);
Evaluate the effectiveness and significance of the information you have obtained.
Compare the success rate of predicted responders and non-responders within different regions and across the company. Is the success statistically significant?
SELECT responder, cust_region,
COUNT(*) AS cnt,
SUM(post_purch – pre_purch) AS tot_increase,
AVG(post_purch – pre_purch) AS avg_increase,
STATS_T_TEST_PAIRED(pre_purch, post_purch) AS significanceFROM ( SELECT cust_name, cust_region PREDICTION(campaign_model USING *) AS responder, SUM(CASE WHEN purchase_date < 15-Apr-2005 THEN purchase_amt ELSE 0 END) AS pre_purch, SUM(CASE WHEN purchase_date >= 15-Apr-2005 THEN purchase_amt ELSE 0 END) AS post_purch FROM customers, sales, products@PRODDB WHERE sales.cust_id = customers.cust_id AND purchase_date BETWEEN 15-Jan-2005 AND 14-Jul-2005 AND sales.prod_id = products.prod_id AND CONTAINS(prod_description, 'DVD') > 0 GROUP BY cust_id, PREDICTION(campaign_model USING *) )
GROUP BY ROLLUP responder, cust_regionORDER BY 4 DESC;
Predictive analytics, implemented in the
DBMS_PREDICTIVE_ANALYTICS package, supports routines for making predictions, assessing attribute importance, and creating profiles. Example 1-3 shows how you could use predictive analytics to generate a customer profile.
See Also:Oracle Data Mining Concepts for an overview of Oracle predictive analytics
PROFILE statement in Example 1-3 returns rules that suggest whether or not a customer is likely to use an affinity card. The rules are generated based on two predictors: customer gender and customer occupation. The rules are written as XML to a results table with these columns.
Name Type ------------------------- ------------ PROFILE_ID NUMBER RECORD_COUNT NUMBER DESCRIPTION XMLTYPE
The rule identifier is stored in
PROFILE_ID. The number of cases described by the rule is stored in
RECORD_COUNT. The XML that describes the rule is stored in the
DESCRIPTION column.
Note:This example uses sample data based on the
SH schema. This data is used with the Data Mining sample programs. For information on the sample programs, see Oracle Data Mining Administrator's Guide.
Example 1-3 Generate a Customer Profile
--create a source view CREATE VIEW cust_gend_occ_view AS SELECT cust_gender, occupation, affinity_card FROM mining_data_apply; -- describe the source data DESCRIBE cust_gend_occ_view Name Null? Type ---------------------------------------------- CUST_GENDER VARCHAR2(1) OCCUPATION VARCHAR2(21) AFFINITY_CARD NUMBER(10) -- find the rules BEGIN DBMS_PREDICTIVE_ANALYTICS.PROFILE( DATA_TABLE_NAME => 'cust_gend_occ_view', TARGET_COLUMN_NAME => 'affinity_card', RESULT_TABLE_NAME => 'profile_result'); END; / -- PROFILE has created 5 rules SELECT profile_id from cust_gend_occ_profile_results; PROFILE_ID ---------- 1 2 3 4 5 -- display the rules <SimpleRule id="1" score="1" recordCount="275"> <CompoundPredicate booleanOperator="and"> <SimpleSetPredicate field="OCCUPATION" booleanOperator="isIn"> <Array type="string">"Exec." "Prof." "Protec." </Array> </SimpleSetPredicate> <SimpleSetPredicate field="CUST_GENDER" booleanOperator="isIn"> <Array type="string">"M"</Array> </SimpleSetPredicate> </CompoundPredicate> <ScoreDistribution value="1" recordCount="146"/> <ScoreDistribution value="0" recordCount="129"/> </SimpleRule> <SimpleRule id="2" score="0" recordCount="124"> <CompoundPredicate booleanOperator="and"> <SimpleSetPredicate field="OCCUPATION" booleanOperator="isIn"> <Array type="string">"Exec." "Prof." "Protec." </Array> </SimpleSetPredicate> <SimpleSetPredicate field="CUST_GENDER" booleanOperator="isIn"> <Array type="string">"F" </Array> </SimpleSetPredicate> </CompoundPredicate> <ScoreDistribution value="0" recordCount="96"/> <ScoreDistribution value="1" recordCount="28"/> </SimpleRule> <SimpleRule id="3" score="0" recordCount="397"> <CompoundPredicate booleanOperator="and"> <SimpleSetPredicate field="CUST_GENDER" booleanOperator="isIn"> <Array type="string">"M" </Array> </SimpleSetPredicate> <SimpleSetPredicate field="OCCUPATION" booleanOperator="isIn"> <Array type="string">"Crafts" "Sales" "TechSup" "Transp." </Array> </SimpleSetPredicate> </CompoundPredicate> <ScoreDistribution value="0" recordCount="289"/> <ScoreDistribution value="1" recordCount="108"/> </SimpleRule> <SimpleRule id="4" score="0" recordCount="316"> <CompoundPredicate booleanOperator="and"> <SimpleSetPredicate field="CUST_GENDER" booleanOperator="isIn"> <Array type="string">"M" </Array> </SimpleSetPredicate> <SimpleSetPredicate field="OCCUPATION" booleanOperator="isIn"> <Array type="string"> "?" "Cleric." "Farming" "Handler" "House-s" "Machine" "Other" </Array> </SimpleSetPredicate> </CompoundPredicate> <ScoreDistribution value="0" recordCount="277"/> <ScoreDistribution value="1" recordCount="39"/> </SimpleRule <SimpleRule id="5" score="0" recordCount="388"> <CompoundPredicate booleanOperator="and"> <SimpleSetPredicate field="OCCUPATION" booleanOperator="isIn"> <Array type="string"> "?" "Cleric." "Crafts" "Farming" "Handler" "House-s" "Machine" "Other" "Sales" "TechSup" "Transp." </Array> </SimpleSetPredicate> <SimpleSetPredicate field="CUST_GENDER" booleanOperator="isIn"> <Array type="string">"F" </Array> </SimpleSetPredicate> </CompoundPredicate> <ScoreDistribution value="0" recordCount="363"/> <ScoreDistribution value="1" recordCount="25"/> </SimpleRule>
This section describes the new features of Oracle Data Mining 11g Release 1 (11.1) and provides pointers to additional information. Descriptions of new features in the previous release are also retained to help you migrate to the current release.
The following topics describe the new features in Oracle Data Mining:
Mining Model schema objects
In Oracle 11g, Data Mining models are implemented as data dictionary objects in the
SYS schema. A set of new data dictionary views present mining models and their properties. New system and object privileges control access to mining model objects.
In previous releases, Data Mining models were implemented as a collection of tables and metadata within the
DMSYS schema. In Oracle 11g, the
DMSYS schema no longer exists.
See Also:
Oracle Data Mining Administrator's Guide for information about privileges for accessing mining models
"Mining Model Schema Objects" for information about Oracle Data Mining data dictionary views
Automatic and Embedded Data Preparation (ADP and EDP)
In most cases, data must be transformed using techniques such as binning, normalization, or missing value treatment before it can be mined. Data for build, test, and apply must undergo the exact same transformations.
In previous releases, data transformation was the responsibility of the user. In Oracle Database 11g, the data preparation process can be automated. Algorithm-appropriate transformation instructions are embedded in the model and automatically applied to the build data and scoring data. The automatic transformations can be complemented by or replaced with user-specified transformations.
Because they contain the instructions for their own data preparation, mining models are known as supermodels.
See Also:
Oracle Data Mining Concepts for information about automatic, embedded, and custom data transformation for Data Mining
Oracle Database PL/SQL Packages and Types Reference for information about
Scoping of Nested Data and Enhanced Handling of Sparse Data
Oracle Data Mining supports nested data types for both categorical and numerical data. Multi-record case data must be transformed to nested columns for mining.
In Oracle Data Mining 10gR2, nested columns were processed as top-level attributes; the user was burdened with the task of ensuring that two nested columns did not contain an attribute with the same name. In Oracle Data Mining 11g, nested attributes are scoped with the column name, which relieves the user of this burden.
Handling of sparse data and missing values has been standardized across algorithms in Oracle Data Mining 11g. Data is sparse when a high percentage of the cells are empty but all the values are assumed to be known. This is the case in market basket data. When some cells are empty, and their values are not known, they are assumed to be missing at random. Oracle Data Mining assumes that missing data in a nested column is a sparse representation, and missing data in a non-nested column is assumed to be missing at random.
In Oracle Data Mining 11g, Decision Tree and O-Cluster algorithms do not support nested data.
See Also:"Nested Data"
Generalized Linear Models
A new algorithm, Generalized Linear Models, is introduced in Oracle 11g. It supports two mining functions: classification (logistic regression) and regression (linear regression).
See Also:Oracle Data Mining Concepts for information about Generalized Linear Models
New SQL Data Mining Function
A new SQL Data Mining function,
PREDICTION_BOUNDS, has been introduced for use with Generalized Linear Models.
PREDICTION_BOUNDS returns the confidence bounds on predicted values (regression models) or predicted probabilities (classification).
Enhanced Support for Cost-Sensitive Decision Making
Cost matrix support is significantly enhanced in Oracle 11g. A cost matrix can be added or removed from any classification model using the new procedures,
DBMS_DATA_MINING.ADD_COST_MATRIX and
The SQL Data Mining functions support new syntax for specifying an in-line cost matrix. With this new feature, cost-sensitive model results can be returned within a SQL statement even if the model does not have an associated cost matrix for scoring.
Only Decision Tree models can be built with a cost matrix.
See Also:
Oracle Data Mining Concepts for information about costs
Oracle Database PL/SQL Packages and Types Reference for information about
Desupported Features
DMSYS schema
Oracle Data Mining Scoring Engine
In Oracle 10.2, you could use Database Configuration Assistant (DBCA) to configure the Data Mining option. In Oracle 11g, you do not need to use DBCA to configure the Data Mining option.
Basic Local Alignment Search Tool (BLAST)
Deprecated Features
Adaptive Bayes Network classification algorithm (replaced with Decision Tree)
DM_USER_MODELS view and functions that provide information about models, model signature, and model settings (for example,
GET_DEFAULT_SETTINGS, and
GET_MODEL_SIGNATURE). These are replaced by data dictionary views. See Chapter 5 for information about the data dictionary views.
The Oracle Data Mining Java API (OJDM) fully supports the new features in Oracle Data Mining 11g Release 1 (11.1). This section provides a summary of the new features in the Java API. For details, see Oracle Data Mining Java API Reference (Javadoc).
As described in "Mining Model schema objects", mining models in 11g Release 1 (11.1) are data dictionary objects in the SYS schema. System and object privileges control access to mining models.
In the Oracle Data Mining Java API, a new extension method OraConnection.getObjectNames is added to support listing of mining objects that can be accessed by a user. This method provides various object filtering options that applications can use as needed.
As described in "Automatic and Embedded Data Preparation (ADP and EDP)", Oracle Data Mining 11g Release 1 (11.1) supports automatic and embedded data preparation (supermodels).
In the Oracle Data Mining Java API, a new build setting extension method,
OraBuildSettings.useAutomatedDataPreparations, is added to enable ADP. Using the new
OraBuildTask.setTransformationSequenceName, applications can embed the transformations with the model.
Two new GLM packages are introduced:
oracle.dmt.jdm.algorithm.glm and
oracle.dmt.jdm.modeldetail.glm. These packages have GLM algorithm settings and model details interfaces respectively.
New apply content enumeration values,
probabilityLowerBound and
probabilityUpperBound, are added to specify probability bounds for classification apply output. The enumeration
oracle.dmt.jdm.supervised.classification.OraClassificationApplyContent specifies these enumerations. Similarly apply contents enumeration values
predictionLowerBound and
predictionUpperBound are added to specify prediction bounds for regression model apply output. In this release only GLM models support this feature.
New static methods
addCostMatrix and
removeCostMatrix are added to
OraClassificationModel to support associating a cost matrix with the model. This will greatly ease the deployment of costs along with the model.
Mining task features are enhanced to support the building of mining process workflows. Applications can specify dependent tasks using the new
OraTask.addDependency method. Another notable new task feature is
overwriteOutput, which can be enabled by calling the new
OraTask.overwriteOutput method.
With these new features, applications can easily develop mining process workflows and deploy them to the database server. These task workflows can be monitored from the client side. For usage of these methods refer to the demo programs shipped with the product (See Oracle Data Mining Administrator's Guide for information about the demo programs.)
A new mining object,
oracle.dmt.jdm.transform.OraTransformationSequence supports the specification of user-defined transformation sequences. These can either be embedded in the mining model or managed externally. In addition, the new
OraExpressionTransform object can be used to specify SQL expressions to be included with the model.
oracle.dmt.jdm.OraProfileTask is added to support the new predictive analytics profile functionality.
The Oracle Data Mining Java API can be used with Oracle Database 11g Release 1 (11.1) and with Oracle Database 10.2. When used with a 10.2 database, only the 10.2 features are available.
Java Data Mining (JDM) compliant Java API
Oracle 10g Release 2 introduced a completely new Java API for Data Mining. The API implements JSR-000073, developed through the Java Community Process (
The new Java API is layered on the PL/SQL API, and the two APIs are fully interoperable. The new Java API is not compatible with the Java API available in the previous release (Oracle 10g Release 1).
SQL built-in functions for Data Mining
New built-in SQL functions support the scoring of classification, regression, clustering, and feature extraction models. Within the context of standard SQL statements, pre-created models can be applied to new data and the results returned for further processing. The Data Mining SQL functions are:
Predictive Analytics
Predictive Analytics automates the process of data mining. Without user intervention, Predictive Analytics routines manage data preparation, algorithm selection, model building, and model scoring.
In the
DBMS_PREDICTIVE_ANALYTICS PL/SQL package, Oracle Data Mining provides Predictive Analytics routines that calculate predictions and determine the relative influence of attributes on the prediction.
Oracle Spreadsheet Add-In for Predictive Analytics implements
DBMS_PREDICTIVE_ANALYTICS within the context of an Excel spreadsheet. The Spreadsheet Add-In is distributed on Oracle Technology Network.
New and enhanced algorithms
The new Decision Tree algorithm generates human-understandable rules for a prediction.
The new One-Class Support Vector Machine algorithm supports anomaly detection.
The support Vector Machine algorithm is enhanced with active learning for the management of large build data sets.
The PL/SQL and Java API both support the O-Cluster algorithm. In Oracle 10g Release 1, O-Cluster was only supported in the Java API.
This chapter explains how to use data mining models to mine your data.
This chapter contains the following sections:
Scoring, the application of models to new data, is a primary objective of data mining. Once the models have been built, the challenges come in deploying them to obtain the best results, and in maintaining them within a production environment.
In traditional data mining, models are built using specialized software on a remote system and deployed to another system for scoring. This is a cumbersome, error-prone process open to security violations and difficulties in data synchronization.
With Oracle Data Mining, scoring is easy and secure. The scoring engine and the data both reside within the database. Scoring is an extension to the SQL language, so the results of mining can easily be incorporated into applications and reporting systems.
In-database mining provides security, backup and recovery, and high performance. It minimizes the IT effort needed to support data mining initiatives. Using standard database techniques, models can easily be refreshed (re-created) on more recent data and redeployed. The deployment is immediate since the scoring query remains the same; only the underlying model is replaced in the database.
Deploying a model means using it within a target environment. Model deployment could be:
Extracting model details to produce reports. For example: the rules from a Decision Tree model, or the attribute rankings from an Attribute Importance model
Extending the business intelligence infrastructure of a data warehouse by incorporating mining results in applications or operational systems
Moving a model from the database where it was built to the database where it will be used for scoring (export/import)
See Also:Oracle Data Mining Administrator's Guide for information about exporting and importing data mining models
Oracle Data Mining SQL functions enable prediction, clustering, and feature extraction analysis to be easily integrated into live production and operational systems. Because mining results are returned within SQL queries, mining can occur in real time.
With real-time scoring, point-of-sales database transactions can be mined. Predictions and rule sets can be generated to help front-line workers make better analytical decisions. Real-time scoring enables fraud detection, identification of potential liabilities, and recognition of better marketing and selling opportunities.
The query in Example 6-1 uses a Decision Tree model named
dt_sh_clas_sample to predict the probability that customer 101488 will use an affinity card. A customer representative could retrieve this information in real time when talking to this customer on the phone. Based on the query result, the representative might offer an extra-value card, since there is a 73% chance that the customer will use a card.
Example 6-1 Real-Time Query with Prediction Probability
SELECT PREDICTION_PROBABILITY(dt_sh_clas_sample, 1 USING *) cust_card_prob FROM mining_data_apply_v WHERE cust_id = 101488; CUST_CARD_PROB-------------- .727642276
Oracle Data Mining supports six SQL functions that return results from predictive models (classification or regression).
Predictive models produce a target value for each row (case) in the scoring data. Each SQL function returns different information from the scoring results.
See Also:Oracle Data Mining Concepts for information on classification and regression
(Classification or regression). For classification, the
PREDICTION function returns the target value that is predicted with the highest probability (or lowest cost, if costs are specified). For regression,
PREDICTION returns the best predicted target value.
PREDICTION supports costs for classification. See "Cost-Sensitive Decision Making".
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
(Classification or regression) The
PREDICTION_BOUNDS function returns the upper and lower confidence bounds computed by the model.
Confidence is the degree of certainty that the true value (regression) or probability (classification) lies within the bounded interval. The default confidence is .95. Confidence can be specified by the user in the
GLMS_CONF_LEVEL setting for the model. You can override the confidence associated with the model by specifying the confidence inline when you invoke the
PREDICTION_BOUNDS function.
No confidence bounds are returned if ridge regression is being used by the algorithm.
See Also:
(Classification only) The
PREDICTION_COST function returns the cost associated with the class that is predicted with the lowest cost. If you specify a class, the function returns the cost associated with that class.
Costs are a user-specified biasing mechanism for classification. See "Cost-Sensitive Decision Making".
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
(Classification only) The
PREDICTION_DETAILS function returns the rule of a Decision Tree model corresponding to the given prediction. A rule is the condition (combination of attribute values) that leads to a specific classification.
Decision Tree rule identifiers are returned as XML. The full rules can be retrieved with the
GET_MODEL_DETAILS_XML function.
See Also:
(Classification only) The
PREDICTION_PROBABILITY function returns the probability associated with the best prediction (prediction with the highest probability) or the probability associated with the class that you specify.
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
(Classification only) The
PREDICTION_SET function returns all the target classes, associated probabilities, and associated costs (if specified) for each scored row. You can specify parameters to restrict the output of the function.
See Also:
Oracle Data Mining supports three SQL functions that return results when applying clustering models.
Clustering models assign each row to a cluster with an associated probability. Each SQL function returns different information from the scoring results.
See Also:Oracle Data Mining Concepts for information on clustering
CLUSTER_ID function returns the identifier of the cluster predicted with the highest probability.
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
CLUSTER_PROBABILITY function returns the probability associated with the cluster to which cases are most likely to be assigned. If you specify a cluster ID, the function returns the probability associated with that cluster.
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
Oracle Data Mining supports three SQL functions that return results from feature extraction models.
Feature extraction models combine the attributes into a set of features that capture important characteristics of the data. The scoring process generates a value of each feature for each row. The value is a number that identifies the match quality of the case to the feature. Each SQL function returns different information from the scoring results.
FEATURE_ID function returns the identifier of the feature with the highest value (match quality) for the data.
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
FEATURE_VALUE function returns the highest feature value. If you specify a feature ID, the function returns the value of that feature.
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
FEATURE_SET function returns the values associated with each feature for each scored row. You can specify parameters to restrict the output of the function.
See Also:Oracle Database SQL Language Reference for syntax and an example that uses
If you wish to save the results of a scoring function, you can store them in a table.
This example shows how to save the results of scoring a customer response model.
UPDATE CUST_RESPONSE_APPLY_UPDATE SET prediction = prediction(CUST_RESPONSE19964_DT using *), probability = prediction_probability(CUST_RESPONSE19964_DT using *)
The table in question has all of the predictors, and has columns to hold the prediction and probability. The assumption is that any necessary transformations are embedded in the model (otherwise the using clause would need to contain them).
Costs are user-specified numbers that bias classification. The algorithm uses positive numbers to penalize more expensive outcomes over less expensive outcomes. Higher numbers indicate higher costs. The algorithm uses negative numbers to favor more beneficial outcomes over less beneficial outcomes. Lower negative numbers indicate higher benefits.
All classification algorithms can use costs for scoring. You can specify the costs in a cost matrix table, or you can specify the costs inline when scoring. The
PREDICTION_COST, and
PREDICTION_SET functions all support costs.
A sample cost matrix table is shown in Table 6-1.
Table 6-1 Sample Cost Matrix Table
The cost matrix in Table 6-1 specifies costs for a binary target. The matrix indicates that the algorithm should treat a misclassified 0 as twice as costly as a misclassified 1. If the table name is
cost_tbl and it is associated with the Naive Bayes model
nb_sh_clas_sample, then the following query takes
cost_tbl into account when scoring
nb_sh_clas_sample. The output will be restricted to those rows where a prediction of 1 is less costly then a prediction of 0.
SELECT cust_gender, COUNT(*) AS cnt, ROUND(AVG(age)) AS avg_age FROM mining_data_apply_v WHERE PREDICTION (nb_sh_clas_sample COST MODEL USING cust_marital_status, education, household_size) = 1 GROUP BY cust_gender ORDER BY cust_gender;
If there is a possibility that the cost matrix table is not present, or that a cost matrix was not specified for the model, you can use the
AUTO keyword with
MODEL so that scoring only uses costs if the cost matrix is available.
SELECT cust_gender, COUNT(*) AS cnt, ROUND(AVG(age)) AS avg_age FROM mining_data_apply_v WHERE PREDICTION (nb_sh_clas_sample COST MODEL AUTO USING cust_marital_status, education, household_size) = 1 GROUP BY cust_gender ORDER BY cust_gender;
You can specify the costs inline when you invoke the scoring function. The inline costs are used for scoring even if a cost matrix table is associated with the model. Here is the same query with the costs specified inline.
SELECT cust_gender, COUNT(*) AS cnt, ROUND(AVG(age)) AS avg_age FROM mining_data_apply_v WHERE PREDICTION (nb_sh_clas_sample COST (0,1) values ((0, 2), (1, 0)) USING cust_marital_status, education, household_size) = 1 GROUP BY cust_gender ORDER BY cust_gender;
To associate a cost matrix table with a model for scoring, use the
ADD_COST_MATRIX procedure in the
DBMS_DATA_MINING package. You can retrieve the cost matrix with the
GET_COST_MATRIX function. The
REMOVE_COST_MATRIX procedure removes the cost matrix. If you want to use a different cost matrix table with a model, first remove the existing one then add the new one.
-- add cost matrix table cost_tbl -- to model nb_sh_clas_sample -- for scoring -- EXEC DBMS_DATA_MINING.ADD_COST_MATRIX('nb_sh_clas_sample', 'cost_tbl'); -- -- replace cost_tbl with cost_tbl_2 -- EXEC DBMS_DATA_MINING.REMOVE_COST_MATRIX('nb_sh_clas_sample', 'cost_tbl'); EXEC DBMS_DATA_MINING.ADD_COST_MATRIX('nb_sh_clas_sample', 'cost_tbl_2');
The Decision Tree algorithm can use costs to bias the model build. If you want to create a Decision Tree model with costs, create a cost matrix table and provide its name in the
CLAS_COST_TABLE_NAME setting for the model. If you specify costs when scoring the model, the cost matrix used to create the model will be used. If you want to use a different cost matrix table for scoring, first remove the existing cost matrix table then add the new one.
Oracle Data Mining supports a batch apply operation that writes the results of scoring directly to a table. The columns in the table are mining function-dependent. The apply operation is accomplished by
APPLY creates an output table with the columns shown in Table 6-2.
Table 6-2 APPLY Output Table
|Mining Function
|Output Columns
anomaly detection (one-class SVM)
feature extraction
Example 6-2 illustrates anomaly detection with
APPLY. The query of the
APPLY output table returns the ten first customers in the table. Each has a a probability for being typical (1) and a probability for being anomalous (0).
Example 6-2 Anomaly Detection with DBMS_DATA_MINING.APPLY
EXEC dbms_data_mining.apply ('SVMO_SH_Clas_sample','svmo_sh_sample_prepared', 'cust_id', 'one_class_output'); SELECT * from one_class_output where rownum < 11; CUST_ID PREDICTION PROBABILITY ---------- ---------- ----------- 101798 1 .567389309 101798 0 .432610691 102276 1 .564922469 102276 0 .435077531 102404 1 .51213544 102404 0 .48786456 101891 1 .563474346 101891 0 .436525654 102815 0 .500663683 102815 1 .499336317
Whether performed by
APPLY or by a SQL scoring function, scoring generates the same mining results. Classification produces a prediction and a probability for each case; clustering produces a cluster ID and a probability for each case, and so on. The difference lies in the way that scoring results are captured and the mechanisms that can be used for retrieving them.
APPLY output is stored separately from the scoring data, it must be joined to the scoring data to support queries that include the data attributes being mined (the scored rows). Thus any model that will�� be used with
APPLY must have a case ID.
A case ID is not required for models that will be applied with SQL scoring functions. Likewise, storage and joins are not required, since scoring results are generated and consumed in real time within a SQL query.
The SQL scoring functions offer flexibility. You can invoke the function that returns the specific information you need. You simply reference a model and identify the kind of mining results you want to retrieve.
Oracle Data Mining supports the mining of data sets that have one or more text columns. These columns must undergo a special preprocessing step whereby text tokens known as terms are extracted and stored in a nested column. The transformed text can then be used as any other attribute in the building, testing, and scoring of models. Any algorithm that supports nested data can be used for text mining. (See Table 3-2 in Chapter 3.)
This chapter explains how to use PL/SQL to prepare a column of text for mining.
Note:Oracle Data Mining includes sample programs that illustrate text transformation and text mining in both PL/SQL and Java. Refer to Oracle Data Mining Administrator's Guide for information about the Oracle Data Mining sample programs.
See Also:
"Using Text Transformation" for information about the text transformation interface n the Java API
Oracle Data Mining Concepts for information about text mining
This chapter contains the following sections.
Oracle Data Mining uses specialized Oracle Text routines to preprocess text data. Oracle Text is a technology within the database for building text querying and classification applications.
Oracle Text provides the following facilities for the Oracle Data Mining term extraction process:
SVM_CLASSIFIER, defined in the
CTX_DLL Oracle Text PL/SQL package, specifies an index preference for Oracle Data Mining term extraction.
CTXSYS.DRVODM Oracle Text PL/SQL package defines the table functions,
FEATURE_PREP and
FEATURE_EXPLAIN, which generate intermediate and final tables of text terms for Oracle Data Mining.
In PL/SQL, the term extraction process requires the use of these Oracle Text facilities. Java developers can use the
OraTextTransform interface, which presents the Oracle Text term extraction capability within the context of a Java environment. (See "Using Text Transformation".)
See Also:Oracle Text Application Developer's Guide and Oracle Text Reference for information on Oracle Text
Note:The Oracle Text facilities for Oracle Data Mining are documented in this chapter. They are not documented in the Oracle Text manuals.
Note on Terminology:Text terms are also known as features. In text mining, a feature is a word or group of words extracted from a text document. Features (terms) are the fundamental unit of text that can be manipulated and analyzed.
The feature extraction mining function (NMF algorithm in Oracle Data Mining) and text mining transformation both perform a kind of feature extraction.
A good place to start in learning the term extraction process is with the sample programs. The following sample programs contain term extraction code for text mining:
dmsh.sql — Prepares the build, test, and scoring data for the sample programs, including the text mining programs.
dmsh.sql creates views for data mining and tables and indexes for text mining.
dmtxtfe.sql — Using the indexed text column created by
dmsh.sql, creates a nested column suitable for text mining.
dmtxtfe.sql program is a sample term extractor. It contains extensive comments that explain the code in a step-by-step fashion. You can expand this program into a complete term extraction solution by adding index creation and the preparation of test and scoring data (as in
Two sample PL/SQL programs use the data prepared by
dmsh.sql to mine text.
dmtxtnmf.sql creates and applies a model that uses Non-Negative Matrix Factorization.
dmtxtsvm.sql creates and applies a model that uses SVM classification.
Both these programs mine a table of customer data that includes a nested column of text data called
COMMENTS. The
COMMENTS column has been pre-processed by
dmsh.sql. The models created by these programs are referenced in the following example from a Linux system.
-- Run the programs to create the models SQL> @ $ORACLE_HOME/rdbms/demo/dmtxtnmf.sql SQL> @ $ORACLE_HOME/rdbms/demo/dmtxtsvm.sql -- List the models created by the programs SQL> SELECT model_name, mining_function, algorithm FROM user_mining_models; MODEL_NAME MINING_FUNCTION ALGORITHM ------------------------ --------------------------- ------------------------ T_SVM_CLAS_SAMPLE CLASSIFICATION SUPPORT_VECTOR_MACHINES T_NMF_SAMPLE FEATURE_EXTRACTION NONNEGATIVE_MATRIX_FACTOR
See Also:Oracle Data Mining Administrator's Guide. This manual provides instructions for obtaining and running the sample programs. It includes information about the build, training, and scoring data used by these programs.
The pre-processing steps for text mining create nested table columns of type
DM_NESTED_NUMERICALS from columns of type
VARCHAR2 or
CLOB. Each row of the nested table specifies an attribute name and a value. The
DM_NESTED_NUMERICALS type defines the following columns.
attribute_name VARCHAR2(4000) value NUMBER)
The term extraction process treats the text in each row of the original table as a separate document. Each document is transformed to a set of terms that have a numeric value and a text label. Within the nested table column, the
attribute_name column holds the text and the
value column holds the numeric value of the term, which is derived using the term frequency in the document and in the document collection (other rows).
For example, the following query returns various attributes of customer 102998, including a text column of comments. The text column has not been transformed.
SQL> select cust_id, cust_gender, cust_income_level, affinity_card, comments from mining_build_text where cust_id = 102998; CUST_ID C CUST_INCOME_LEVEL AFFINITY_CARD COMMENTS ------- -- -------------------- ------------- -------------------------------- 102998 M J: 190,000 - 249,999 1 I wanted to write you to let you know that I've purchased several items at your store recently and have been very satisfied with my purchases. Keep up the good work.
The following query returns the same attributes of customer 102998, but the text in the comments column has been transformed. The query extracts the
ATTRIBUTE_NAME and
VALUE columns from the nested table that holds the transformed text.
SQL> select b.cust_id, b.cust_gender, b.cust_income_level, b.affinity_card, n.* from mining_build_nested_text b, table(b.comments) n where b.cust_id = 102998 order by n.attribute_name; CUST_ID C CUST_INCOME_LEVEL AFFINITY_CARD ATTRIBUTE_NAME VALUE ------- -- ------------------- ------------- -------------- -------- 102998 M J: 190,000 - 249,999 1 GOOD .26894 102998 M J: 190,000 - 249,999 1 ITEMS 158062 102998 M J: 190,000 - 249,999 1 KEEP 238765 102998 M J: 190,000 - 249,999 1 KNOW .2006 102998 M J: 190,000 - 249,999 1 LET 299856 102998 M J: 190,000 - 249,999 1 PURCHASED 142743 102998 M J: 190,000 - 249,999 1 PURCHASES 173146 102998 M J: 190,000 - 249,999 1 RECENTLY .195223 102998 M J: 190,000 - 249,999 1 SATISFIED .355851 102998 M J: 190,000 - 249,999 1 SEVERAL .355851 102998 M J: 190,000 - 249,999 1 STORE .0712537 102998 M J: 190,000 - 249,999 1 UP .159838 102998 M J: 190,000 - 249,999 1 WANTED .355851 102998 M J: 190,000 - 249,999 1 WORK .299856 102998 M J: 190,000 - 249,999 1 WRITE .355851
ATTRIBUTE_NAME column holds an item of text from the original comments column. The
VALUE column holds the term value. Note that not all words from the original comments column are extracted as terms. For example, the articles
the and
to are not included.
The steps in the term extraction process are summarized in this section. Further details and specific syntax requirements are explained later in this chapter.
First transform the text in the build data. During this process you will generate the text term definitions, which you will reuse for the test and apply data. Perform the following steps:
Create an index on the text column in the build table.
Define a table to hold the categories specified by the
SVM_CLASSIFIER index.
Use the
FEATURE_PREP table function to create the term definitions and populate an intermediate terms table.
Use the
FEATURE_EXPLAIN table function to populate the final terms table.
Replicate the columns of the original build table (using a view or another table), replacing the text column with a nested table column. Load the terms from the final terms table into the nested table column.
The test and apply data must undergo the same pre-processing as the build data. To transform the test and apply data, you will reuse the term definitions generated for the build data. Perform the following steps:
Create an index on the text column in the test or apply table.
Use the
FEATURE_PREP table function to populate an intermediate terms table. Use the term definitions previously generated for the build data.
Use the
FEATURE_EXPLAIN table function to populate the final terms table.
Replicate the columns of the original test or apply table, replacing the text column with a nested table column. Load the terms from the final terms table into the nested table column.
Oracle Text processing requires a text index. Oracle Text supports several types of indexes for querying, cataloging, and classifying text documents. The Oracle Data Mining term extraction process requires a
CONTEXT index for text querying.
You must create an index for each text column to be transformed. Use the following syntax to create the index.
column_name) INDEXTYPE IS ctxsys.context PARAMETERS ('nopopulate');
Note:This statement creates a basic
CONTEXT index. You can further define the characteristics of the index by specifying additional arguments to the
CREATE INDEX statement. Refer to Oracle Text Reference for details.
Oracle Text supports index preferences for overriding the default characteristics of an index. The
CREATE_PREFERENCE procedure in the Oracle Text package
CTX_DDL creates a preference with the name and type that you specify. The
SVM_CLASSIFIER preference type defines the characteristics of an index for Oracle Data Mining.
You must create an index preference when you prepare the build data. It will be reused when you prepare the test and apply data. Use the following syntax to create the index preference.
SQL>EXECUTE ctx_ddl.create_preference(
'preference_name', 'SVM_CLASSIFIER');
SVM_CLASSIFIER index preference uses a predefined table with two numeric columns:
ID and
ID holds the case ID;
CAT holds the category. The category table is used for internal processing. You must create the category table using the following syntax.
category_table_name(id NUMBER, cat NUMBER);
FEATURE_PREP table function in the
CTXSYS.DRVODM Oracle Text package extracts terms from a text column using an index preference of type
FEATURE_PREP creates a table of term definitions from the build data and reuses these definitions for the test and apply data.
FEATURE_PREP returns an intermediate terms table.
FEATURE_PREP is an over-loaded function that accepts two different sets of arguments. You will specify one set of arguments for the build data and another set for the test and apply data.
--- syntax for build data --- CTXSYS.DRVODM.FEATURE_PREP ( text_index IN VARCHAR2, case_id IN VARCHAR2, category_tbl IN VARCHAR2, category_tbl_id_col IN VARCHAR2, category_tbl_cat_col IN VARCHAR2, feature_definition_tbl IN VARCHAR2, index_preference IN VARCHAR2) RETURN DRVODM; --- syntax for test/apply data --- CTXSYS.DRVODM.FEATURE_PREP ( text_index IN VARCHAR2, case_id IN VARCHAR2, feature_definition_tbl IN VARCHAR2, RETURN DRVODM;
FEATURE_PREP returns the following columns. The
SEQUENCE_ID column holds the case ID; the
ATTRIBUTE_ID column holds the term ID.
Name NULL? Type ---------------------- ------- ------ SEQUENCE_ID NUMBER ATTRIBUTE_ID NUMBER VALUE NUMBER
FEATURE_PREP accepts the arguments described in Table 4-1.
Table 4-1 FEATURE_PREP Table Function Arguments
|Argument Name
|Data Type
Name of the index on the text column in the build, test, or apply table.
Name of the case ID column in the build, test, or apply table.
Name of the table used by the
Specify this argument only for build data.
Specify 'id'. This is the name of the
Specify this argument only for build data.
Specify 'cat'. This is the name of the
Specify this argument only for build data.
Name of the term definition table created by
Name Null? Type --------------------------------- CAT_ID NUMBER TYPE NUMBER RULE BLOB
Name of the
Specify this argument only for build data.
The following example creates an intermediate terms table called
txt_term_out. The
FEATURE_PREP table function extracts terms from a text column with an index called
build_text_idx. The text column is in a build table with a case ID column called
cust_id. The index preference
txt_pref is applied to the index using the
id and
cat columns in the table
FEATURE_PREP creates a table of term definitions called
CREATE TABLE txt_term_out AS SELECT * FROM TABLE(ctxsys.drvodm.feature_prep ( 'build_text_idx', 'cust_id', 'cat_tbl', 'id', 'cat', 'txt_pref_terms', 'txt_pref'));
FEATURE_EXPLAIN table function in the
CTXSYS.DRVODM Oracle Text package extracts the term values from the definitions created by
FEATURE_PREP and appends the associated word to each value.
FEATURE_EXPLAIN returns the final terms table.
The calling syntax of
FEATURE_EXPLAIN is described as follows.
CTXSYS.DRVODM.FEATURE_EXPLAIN ( feature_definition_tbl IN VARCHAR2, RETURN DRVODM;
FEATURE_EXPLAIN returns the following columns.
Name Type --------------- --------------- text VARCHAR2(160) type NUMBER(3) ID NUMBER score NUMBER
FEATURE_EXPLAIN accepts a single argument: the terms definition table created by
The following example creates a final terms table called
txt_final_terms using the intermediate terms table
txt_term_out. The
FEATURE_EXPLAIN table function returns the terms specified in the terms definition table
SQL> create table txt_final_terms as select A.sequence_id, B.text, A.value FROM txt_term_out A, TABLE(ctxsys.drvodm.feature_explain( 'txt_pref_terms')) B WHERE A.attribute_id = B.id;
Use the final terms table to populate a nested table column of type
The following example creates the table
mining_build_nested_text. (Alternatively, you could create a view.) The table has a case ID column of customer IDs and three customer attribute columns: age, education, and occupation. It also includes a comments column of type
DM_NESTED_NUMERICALS created from the terms table
SQL> CREATE TABLE mining_build_nested_text NESTED TABLE comments store AS build_comments AS SELECT non_text.cust_id, non_text.age, non_text.education, non_text.occupation, txt.comments FROM mining_build_text non_text, ( SELECT features.sequence_id, cast(COLLECT(dm_nested_numerical(features.text,features.value)) as dm_nested_numericals) comments FROM txt_final_terms features group by features.sequence_id) txt WHERE non_text.cust_id = txt.sequence_id(+);
In the following example, a text column in
MINING_BUILD_TEXT is transformed to a nested table column in
MINING_BUILD_NESTED_TEXT. The same text column in
MINING_APPLY_TEXT is transformed to a nested table column in
MINING_BUILD_TEXT and
MINING_APPLY_TEXT have the following columns.
Name Null? Type --------------------------------- -------- --------------------------- CUST_ID NOT NULL NUMBER AGE NUMBER EDUCATION VARCHAR2(21) OCCUPATION VARCHAR2(21) COMMENTS VARCHAR2(4000)
The following statements create the indexes.
SQL> create index build_text_idx on mining_build_text (comments) indextype is ctxsys.context parameters ('nopopulate'); SQL> create index apply_text_idx ON mining_apply_text (comments) indextype is ctxsys.context parameters ('nopopula�!�te');
The following statements create the index preference and its table.
SQL> execute ctx_ddl.create_preference('idx_pref', 'SVM_CLASSIFIER'); SQL> create table idx_pref_cat (id number, cat number);
The following statement returns the intermediate terms in the table
BUILD_TERMS_OUT. It also creates the table
FEATURE_DEFS and populates it with the term definitions.
SQL> create table build_terms_out as select * from table (ctxsys.drvodm.feature_prep ('build_text_idx', 'cust_id', 'idx_pref_cat', 'id', 'cat', 'feature_defs', 'idx_pref'));
The following statement returns the final terms in the table
SQL> create table build_explain_out as select a.sequence_id, b.text, a.value from build_terms_out a, table (ctxsys.drvodm.feature_explain('feature_defs')) b where a.attribute_id = b.id;
The following statement creates the table
MINING_BUILD_NESTED_TEXT. This table contains the non-text attributes from the original build table and a nested table of comments. This table can be used to build a model.
SQL> create table mining_build_nested_text nested table comments store as build_comments as select non_text.cust_id, non_text.age, non_text.education, non_text.occupation, txt.comments from mining_build_text non_text, (select features.sequence_id, cast(collect(dm_nested_numerical(features.text,features.value)) as dm_nested_numericals) comments from build_explain_out features group by features.sequence_id) txt where non_text.cust_id = txt.sequence_id(+);
The following statement creates the intermediate terms table for the comments column in the apply table,
MINING_APPLY_TEXT. It uses the term definitions in the
FEATURE_DEFS table, which was created during the pre-processing of the comments column in
SQL> create table apply_terms_out as select * from table (ctxsys.drvodm.feature_prep ('build_text_idx', 'cust_id', 'feature_defs'));
The following statement creates the final terms table for apply.
SQL> create table apply_explain_out as select a.sequence_id, b.text, a.value from apply_terms_out a, table (ctxsys.drvodm.feature_explain('feature_defs')) b where a.attribute_id = b.id;
The following statement creates the table
MINING_APPLY_NESTED_TEXT. This table contains the non-text attributes from the original apply table and a nested table of comments. This table can be used to apply the model.
SQL> create table mining_apply_nested_text nested table comments store as apply_comments as select non_text.cust_id, non_text.age, non_text.education, non_text.occupation, txt.comments from mining_apply_text non_text, (select features.sequence_id, cast(collect(dm_nested_numerical(features.text,features.value)) as dm_nested_numericals) comments from apply_explain_out features group by features.sequence_id) txt where non_text.cust_id = txt.sequence_id(+);
This chapter provides an overview of the PL/SQL, SQL, and Java interfaces to Oracle Data Mining.
This chapter contains the following sections:
The PL/SQL interface to Oracle Data Mining is implemented in three packages:
DBMS_DATA_MINING, the primary interface to Oracle Data Mining
DBMS_DATA_MINING_TRANSFORM, convenience routines for data transformation
DBMS_DATA_MINING package includes procedures for:
Creating, dropping, and renaming mining models
Applying a model to new data
Describing the model details
Creating costs and computing test metrics for a classification model
Exporting and importing models
CREATE_MODEL procedure creates a mining model. The attributes, transformations, rules, and other information internal to the model are returned by
GET_MODEL_DETAILS functions. You can also obtain information about mining models by querying data dictionary views, as described in "Data Mining Data Dictionary Views".
APPLY procedure creates a table with specific columns and populates the columns with mining results. The columns of this table vary based on the particular mining function and algorithm.
Note:The Data Mining SQL functions, introduced in Oracle Database 10.2, are now generally the preferred method for applying Data Mining models. See "Data Mining SQL Functions".
This package includes routines for transforming the data to make it suitable for mining. Since Oracle Data Mining supports Automatic Data Transformation (ADP), you will not need to use this package unless you want to implement specialized transformations.
You can supplement the ADP-generated transformations with additional transformations that you specify yourself, or you can elect to transform the data yourself instead of using ADP.
The routines in
DBMS_DATA_MINING_TRANSFORM are convenience routines to assist you in creating your own transformations. If these routines do not entirely suit your needs, you can write SQL to modify their output, or you can write your own routines.
To specify transformations for a model, pass a transformation list to the
DBMS_DATA_MINING.CREATE_MODEL procedure. You can use the
STACK procedures in
DBMS_DATA_MINING_TRANSFORM to build the transformation list.
Oracle Data Mining embeds automatic transformations and transformations you pass to
CREATE_MODEL in the model. The embedded transformations are automatically applied to the data when the model is applied. You do not need to separately transform the test or scoring data.
See Also:
This package includes routines for predictive analytics, an automated form of data mining. With predictive analytics, you do not need to be aware of model building or scoring. All mining activities are handled internally by the predictive analytics procedure.
Predictive analytics routines prepare the data, build a model, score the model, and return the results of model scoring. Before exiting, they delete the model and supporting objects.
Oracle predictive analytics supports these routines:
EXPLAIN ranks attributes in order of influence in explaining a target column.
PREDICT predicts the value of a target column based on values in the input data.
PROFILE generates rules that describe the cases from the input data.
See Also:
DBMS_PREDICTIVE_ANALYTICS in Oracle Database PL/SQL Packages and Types Reference
You can obtain information about mining models from the data dictionary. The data dictionary views for Oracle Data Mining are available for
USER_, and
DBA_ access.
The Data Mining data dictionary views are summarized as follows:
ALL_MINING_MODELS returns information about the mining models to which you have access.
ALL_MINING_MODEL_ATTRIBUTES returns information about the attributes of the mining models to which you have access.
See "About Attributes".
ALL_MINING_MODEL_SETTINGS returns information about the settings for the mining models to which you have access.
See "Model Settings".
The built-in SQL functions for Data Mining implement scoring operations for models that have already been created in the database. They provide the following benefits:
Models can be easily deployed within the context of existing SQL applications.
Scoring operations take advantage of existing query execution functionality. This provides performance benefits, especially in the case of single row scoring.
Scoring results are pipelined, enabling the rows to be returned iteratively as they are produced. Pipelining is an optimization that greatly improves performance. For information about pipelining, see Oracle Database PL/SQL Language Reference.
Note:SQL functions are built into Oracle Database and are available for use within SQL statements. SQL functions should not be confused with functions defined in PL/SQL packages.
When applied to a given row of scoring data, classification and regression models provide the best predicted value for the target and the associated probability of that value occurring. The SQL functions for prediction are described in Table 2-1.
Table 2-1 SQL Functions for Prediction
Returns the best prediction for the target
(GLM only) Returns the upper and lower bounds of the interval wherein the values (linear regression) or probabilities (logistic regression) will lie
Returns a measure of the cost of incorrect predictions
Returns the probability of a given prediction
Returns the results of a classification model, including the predictions and associated probabilities for each case
Applying a cluster model to a given row of scoring data returns the cluster ID and the probability of that row's membership in the cluster. The SQL functions for clustering are described in Table 2-2.
Table 2-2 SQL Functions for Clustering
Returns the ID of the predicted cluster
Returns the probability of a case belonging to a given cluster
Returns a list of all possible clusters to which a given case belongs along with the associated probability of inclusion
Applying a feature extraction model involves the mapping of features (sets of attributes) to columns in the scoring data set. The SQL functions for feature extraction are described in Table 2-3.
Table 2-3 SQL Functions for Feature Extraction
Returns the ID of the feature with the highest coefficient value
Returns a list of objects containing all possible features along with the associated coefficients
Returns the value of a given feature
The Oracle Data Mining Java API is an Oracle implementation of the JDM standard (JSR-73) Java API. It is a thin API developed using the rich in-database functionality of Oracle Data Mining.
The Oracle Data Mining Java API implements Oracle specific extensions to provide all the data mining features available in the database. All extensions are designed to be compliant with the JDM standards extension framework. All the mining functions and algorithms available in the database are exposed through the Oracle Data Mining Java API.
Oracle Database 10.2.0.1 introduced the JDM 1.0 standard compliant API that replaced the old Oracle proprietary Java API in the previous releases. Database 10.2.0.2 patch-set release extended the JDM standards support by implementing Oracle Data Mining Java API compatible with JDM 1.1.
In this release, the Oracle Data Mining Java API continues to be compatible with the JDM 1.1 and provides new data mining functionality in the database server as Oracle extensions. In this release new Oracle features include automatic and embedded data preparation, generalized linear models, transformation sequencing and task dependency specifications.
See Also:Oracle Data Mining Concepts for a summary of the new features in the Oracle Data Mining Java API
JDM is an industry standard Java API for data mining developed under the Java Community Process (JCP). It defines Java interfaces that vendors can implement for their Data Mining Engine (DME). It includes interfaces supporting mining functions such as classification, regression, clustering, attribute importance and association along with specific mining algorithms such as naïve bayes, support vector machines, decision trees, feed forward neural networks, and k-means.
An overview of the Java packages defined by the standards is listed in Table 2-4. For more details, refer to the Java documentation published with the standard at
http://www.jcp.org. In the Go to JSR box, type in
Table 2-4 JDM Standard Java Packages
Defines objects supporting all JDM subpackages.
Defines objects supporting many top-level mining objects. Introduced to avoid cyclic package dependencies.
Defines objects that support connecting to the Data Mining ENgine and executing tasks.
Defines objects supporting logical and physical data, model signature, taxonomy, category set and the generic super class category matrix.
Defines objects supporting attribute statistics.
Defines objects supporting rules and their predicate components.
Defines objects supporting tasks for build, compute statistics, import, and export. Task has an optional subpackage for apply since apply is used mainly for supervised and clustering functions.
Defines objects supporting the build settings and model for association.
Defines objects supporting the build settings and model for clustering.
Defines objects supporting the build settings and model for attribute importance.
Defines objects supporting the build settings and models for supervised learning functions, specifically classification and regression, with corresponding optional packages. It also includes a common test task for the classification and regression functions.
Defines objects supporting the settings that are specific to algorithms. The algorithm package has optional sub packages for different algorithms.
Defines objects supporting details of various model representation. Model Details has optional sub packages for different model details.
Oracle extensions are defined to support the functionality that is not part of the JDM standards. This section gives an overview of these extensions.
See Also:Oracle Data Mining Java API Reference (javadoc).
Oracle extensions have the following major additional features:
Feature Extraction function with the Non-negative Matrix Factorization (NMF) algorithm
Generalized Linear Model algorithm for regression and classification functions
Oracle-proprietary clustering algorithm, Orthogonal Partitioning Clustering (O-CLuster)
Oracle-proprietary classification algorithm, Adaptive Bayes Network (ABN) (deprecated)
Automated and embedded data transformations
Predictive analytics tasks
An overview of the Oracle extensions higher-level Java packages is provided in Table 2-5.
Table 2-5 Oracle Extensions Higher-Level Packages
Defines the objects related to the feature extraction function. Feature extraction supports the scoring operation.
Defines the objects related to the Non-negative Matrix Factorization (NMF) algorithm.
Defines the objects related to the Generalized Linear Model (GLM) algorithm.
Defines the objects related to the Orthogonal Clustering (O-Cluster) algorithm.
Defines the objects related to the Adaptive Bayes Network (ABN) algorithm (deprecated).
Defines the objects related to the transformations.
In JDM, named objects are objects that can be saved using the save method in the Connection. All the named objects are inherited from the
javax.datamining.MiningObject interface. You can choose to persist the named objects either permanently (persistent objects) or only for the lifetime of the Connection object (transient objects).
Table 2-6 lists the JDM named objects supported by Oracle Data Mining.
Table 2-6 JDM Named Objects Supported by Oracle Data Mining
|Persistent Objects
|Transient Objects
|Unsupported Objects
Apply Settings
Logical Data
Build Settings
Physical Dataset
Cost Matrix
Test Metrics
Transformation sequence
Physical data sets refer to the data to be used as input to data mining operations. PhysicalDataSet objects reference specific data identified by a URI. Oracle Data Mining supports a table or view in the same database as a valid physical dataset URI. Syntax of the physical dataset URI is as follows:
Data URI Syntax:
[schemaName.] tableName/viewName
The PhysicalDataSet object can support multiple data representations. Oracle Data Mining supports two types of data representation: single-record case and wide data. (See Chapter 3 for details.) The Oracle Data Mining implementation requires users to specify the case-id column in the physical dataset.
A PhysicalDataSet object is a transient object in the Oracle Data Mining Java API. It is stored in the Connection as an in-memory object.
A BuildSettings object captures the high-level specification input for building a model. The API specifies mining functions: classification, regression, attribute importance, association, clustering, and feature extraction.
Build settings allow a user to specify the type of result desired without having to specify a particular algorithm. Although a build settings object allows for the specification of an algorithm and its settings, if the algorithm settings are omitted, the DME selects an algorithm based on the build settings and possibly characteristics of the data.
Build settings may also be validated for correct parameters using the verify method.
A BuildSettings object is persistent; it is stored as a table with a user-specified name in the user's schema. This settings table is interoperable with the PL/SQL API. Oracle recommends that you not modify the build settings table manually.
The Execute method in the Connection object is used to start an execution of a mining task. Typically, mining operations are done using tables with millions of records, so the execution of operations such as a model build can take a long time.
JDM supports asynchronous execution of mining tasks using
DBMS_SCHEDULER in the database. Each mining task is stored as a
DBMS_SCHEDULER job object in the user's schema. When the user saves the task object, it creates a job object and sets the object to be in the
DISABLED state. When the user executes a task, it enables the job to start execution.
To monitor tasks that are executed asynchronously, the Execute method returns a
javax.datamining.ExecutionHandle object. It provides methods such as
waitForCompletion and
getStatus to retrieve the status details of the task.
A Model object is the result of applying an algorithm to data as specified in a BuildSettings object.
Models can be used in several operations. They can be:
Inspected, for example to examine the rules produced from a decision tree or association
Tested for accuracy
Applied to data for scoring
Exported to an external representation such as native format or PMML
When a model is applied to data, it is submitted to the DME for interpretation. A Model object references its
BuildSettings object as well as the
Task that created it. as.
A TestMetrics object is the result of testing a supervised model with test data. Based on the type of mining function, different test metrics are computed. For classification models, accuracy, confusion-matrix, lift, and receiver-operating characteristic can be computed to access the model. Similarly for regression models, R-squared and RMS errors can be computed.
An ApplySettings object allows users to tailor the results of an apply task. It contains a set of ordered items. Output can consist of:
Data (key attributes) to be passed through to the output from the input dataset.
Values computed from the apply itself: score, probability, and in the case of decision trees, rule identifiers.
Multi-class categories for its associated probabilities. For example, in a classification model with target favoriteColor, users could select the specific colors to receive the probability that a given color is favorite.
Each mining function class defines a method to construct a default apply settings object. This simplifies the programmer's effort if only standard output is desired. For example, typical output for a classification apply would include the top prediction and its probability.
A TransformationSequence object represents the sequence of transformations that are to be performed as part of a mining operation. For example, a Support Vector Machine model build involves outlier handling and normalization transformations. In addition to this, there can be new derived attribute creation and business transformations, and so on. Typically these transformations are reused for other model builds and hence applications can save the transformation sequence as a named object in the API.
Transformation sequences can be used either to perform transformations as a separate task or embed them to the modeling process by specifying it as one of the input objects for model building.
This manual describes the programmatic interfaces to Oracle Data Mining. You can use the PL/SQL and Java interfaces to create data mining applications or add data mining features to existing applications. You can use the data mining SQL operators in applications or in ad hoc queries.
This manual should be used along with the demo applications and the related reference documentation. (See "Related Documentation".)
The preface contains these topics:
This manual is intended for database programmers who are familiar with Oracle Data Mining.
Our goal is to make Oracle products, services, and supporting documentation accessible, with good usability, to the disabled community. To that end, our documentation includes features that make information available to users of assistive technology. This documentation is available in HTML format, and contains markup to facilitate access by the disabled community. Accessibility standards will continue to evolve over time, and Oracle is actively engaged with other market-leading technology vendors to address technical obstacles so that our documentation can be accessible to all of our customers. For more information, visit the Oracle Accessibility Program Web site at
Accessibility of Code Examples in Documentation
Screen readers may not always correctly read the code examples in this document. The conventions for writing code require that closing braces should appear on an otherwise empty line; however, some screen readers may not always read a line of text that consists solely of a bracket or brace.
Accessibility of Links to External Web Sites in Documentation
This documentation may contain links to Web sites of other companies or organizations that Oracle does not own or control. Oracle neither evaluates nor makes any representations regarding the accessibility of these Web sites.
TTY Access to Oracle Support Services
Oracle provides dedicated Text Telephone (TTY) access to Oracle Support Services within the United States of America 24 hours a day, seven days a week. For TTY support, call 800.446.2398.
The documentation set for Oracle Data Mining is part of the Oracle Database 11g Release 1 (11.1) Online Documentation Library. The Oracle Data Mining documentation set consists of the following documents:
Oracle Data Mining Java API Reference (javadoc)
Oracle Data Mining Administrator's Guide
Note:Information to assist you in installing and using the Data Mining demo programs is provided in Oracle Data Mining Administrator's Guide.
Oracle Database PL/SQL Packages and Types Reference (
DBMS_DATA_MINING_TRANSFORM, and
Oracle Database SQL Language Reference (Data Mining functions)
The following text conventions are used in this document:
|Boldface type indicates graphical user interface elements associated with an action, or terms defined in text or the glossary.
|Italic type indicates book titles, emphasis, or placeholder variables for which you supply particular values.
|Monospace type indicates commands within a paragraph, URLs, code in examples, text that appears on the screen, or text that you enter.
This chapter explains how data is interpreted by Oracle Data Mining. It describes the requirements for a data mining case table, and it explains the notion of data attributes and model attributes. Data transformations are discussed in Oracle Data Mining Concepts.
This chapter contains the following sections:
The data that you wish to mine must be defined within a single table or view. The information for each record must be stored in a separate row. The data records are commonly called cases. Each case can be identified by a unique case ID. The table or view itself is referred to as a case table.
CUSTOMERS table in the
SH schema is an example of a table that could be used for mining. All the information for each customer is contained in a single row. The case ID is the
CUST_ID column. The rows listed in Example 3-1 are selected from
Example 3-1 Sample Case Table
SQL> select cust_id, cust_gender, cust_year_of_birth, cust_main_phone_number from sh.customers where cust_id < 11; CUST_ID CUST_GENDER CUST_YEAR_OF_BIRTH CUST_MAIN_PHONE_NUMBER ------- ----------- ---- ------------- ------------------------- 1 M 1946 127-379-8954 2 F 1957 680-327-1419 3 M 1939 115-509-3391 4 M 1934 577-104-2792 5 M 1969 563-667-7731 6 F 1925 682-732-7260 7 F 1986 648-272-6181 8 F 1964 234-693-8728 9 F 1936 697-702-2618 10 F 1947 601-207-4099
The columns of the case table hold the attributes that describe each case. In Example 3-1, the attributes are:
CUST_YEAR_OF_BIRTH, and
CUST_MAIN_PHONE_NUMBER. The attributes are the predictors in a supervised model and the descriptors in an unsupervised model. The case ID,
CUST_ID, can be viewed as a special attribute; it is not a predictor or a descriptor.
Oracle Data Mining accepts the following column data types:
See Oracle Data Mining Concepts for information about converting the data type if necessary.
The nested types are described in "Nested Data". The case ID column cannot have a nested type.
You need two case tables to build a classification or regression model. One set of rows is used for building (training) the model, another set of rows is used for testing the model. It is often convenient to derive the build data and test data from the same data set. For example, you might select 60% of the rows for building the model and 40% for testing the model.
Models that implement other mining functions, such as attribute importance, clustering, association, or feature extraction, do not use separate test data.
Most data mining models can be applied to separate data. The data to which you apply the model is called the apply data or scoring data. Oracle Data Mining supports the scoring operation for classification, regression, anomaly detection, clustering, and feature extraction.
The scoring process matches column names in the scoring data with the names of the columns that were used to build the model. The scoring process does not require all the columns to be present in the scoring data. If the data types do not match, Oracle Data Mining attempts to perform type coercion. For example, if a column called
PRODUCT_RATING is
VARCHAR2 in the build data but
NUMBER in the scoring data, Oracle Data Mining will effectively apply a
TO_CHAR() function to convert it.
The column in the test or scoring data must undergo the same transformations as the corresponding column in the build data. For example, if the
AGE column in the build data was transformed from numbers to the values
ADULT, and
SENIOR, then the
AGE column in the scoring data must undergo the same transformation so that the model can properly evaluate it.
Note:Oracle Data Mining can embed user-specified transformation instructions in the model and reapply them whenever the model is applied. When the transformation instructions are embedded in the model, you do not need to specify them for the test or scoring data sets.
Oracle Data Mining also supports Automatic Data Preparation (ADP). When ADP is enabled, the transformations required by the algorithm are performed automatically and embedded in the model along with any user-specified transformations. Mining models that contain embedded transformations are known as supermodels.
Automatic and embedded data transformations are discussed in Oracle Data Mining Concepts.
Attributes are the items of data used in data mining. In predictive models, attributes are the predictors that affect a given outcome. In descriptive models, attributes are the items of information being analyzed for natural groupings or associations. A table of employee data might contain attributes such as job title, date of hire, salary, age, gender, and so on.
Data attributes are columns in the data sets used to build, test, or score a model. Model attributes are the data representations used internally by the model.
Data attributes and model attributes can be the same. For example a column called
SIZE, with values
M, and
L, might be an attribute used by an algorithm to build a model. Internally, the model attribute
SIZE would most likely be the same as the data attribute from which it was derived.
On the other hand, a nested column
SALES_PROD, containing the sales figures for a group of products, would not correspond to a model attribute. The data attribute would be
SALES_PROD, but each product with its corresponding sales figure (each row in the nested column) would be a model attribute.
Transformations also cause a discrepancy between data attributes and model attributes. For example, a transformation could apply a calculation to two data attributes and store the result in a new attribute. The new attribute would be a model attribute that has no corresponding data attribute. Other transformations such as binning, normalization, and outlier treatment, cause the model's representation of an attribute to be different from the data attribute in the case table.
See Also:
The target of a supervised model is a special kind of attribute. The target column in the build data contains the historical values used to build (train) the model. The target column in the test data contains the historical values to which the predictions are compared. The target column in the scoring data holds the results when the model is applied.
Clustering, feature extraction, association, and anomaly detection models do not use a target.
You can query the *
_MINING_MODEL_ATTRIBUTES view to find the target for a given model, as shown in Example 3-2.
Model attributes are either numerical or categorical. Data attributes, which are columns in a case table, have Oracle data types.
Oracle Data Mining interprets
FLOAT, and
DM_NESTED_NUMERICALS as numerical, and
VARCHAR2, and
DM_NESTED_CATEGORICALS as categorical. There is one exception: If the target of a classification model is
NUMBER or
FLOAT, it will be interpreted as categorical.
Numerical attributes can theoretically have an infinite number of values. The values have an implicit order, and the differences between them are also ordered.
Categorical attributes have values that belong to a finite number of discrete categories or classes. There is no implicit order associated with the values. Some categoricals are binary: They have only two possible values, such as
yes or
no, or
male or
female. The term multi-class is used to describe models when the categorical target has more than two values. For example, a target of clothing sizes could have the values
medium, or
The target of a classification model is categorical. The target of a regression model is numerical. The target of an attribute importance model is either categorical or numerical.
The model signature is the set of data attributes used to build a model. Some or all of the attributes in the signature should be present for scoring. If some columns are not present, they are disregarded. If columns with the same names but different data types are present, the model attempts to convert the data type.
The model signature does not necessarily include all the columns in the build data. Algorithm-specific criteria may cause the model to ignore certain columns. Other columns may be eliminated by transformations. Only the data attributes actually used to build the model are included in the signature.
The target and case ID columns are not included in the signature.
The columns in the model signature, plus the target (if the model is supervised), are listed in the data dictionary view,
ALL/USER/DBA_MINING_MODEL_ATTRIBUTES. When used with the
ALL prefix, this view returns the signature and target for all mining models accessible to the current user. When used with the
USER prefix, it returns the model signature and target for all the mining models in the user's schema. The
DBA prefix is only available to DBAs.
The columns in the
ALL_MINING_MODEL_ATTRIBUTES view are described as follows. Details are in Table 3-1.
SQL> describe all_mining_model_attributes Name Null? Type ---------------------------------------------------------- OWNER NOT NULL VARCHAR2(30) MODEL_NAME NOT NULL VARCHAR2(30) ATTRIBUTE_NAME NOT NULL VARCHAR2(30) ATTRIBUTE_TYPE VARCHAR2(11) DATA_TYPE VARCHAR2(12) DATA_LENGTH NUMBER DATA_PRECISION NUMBER DATA_SCALE NUMBER USAGE_TYPE VARCHAR2(8) TARGET VARCHAR2(3)
Table 3-1 ALL_MINING_MODEL_ATTRIBUTES
Owner of the mining model.
Name of the mining model.
Name of the data attribute (column).
Type of the model attribute derived by the model from the data attribute. The attribute type can be either numerical or categorical.
This information is only meaningful if there is a one-to-one mapping between the data attribute and the model attribute. If the data attribute has undergone transformations that change the way it is used by the model, then the
The Oracle data type of the data attribute (column):
If the value is
If the data type is
See "Nested Data" for details.
Length of the data type
Precision of a fixed point number, which is the total number of significant decimal digits, is represented as p in the data type
Scale of a fixed point number. Scale, which is the number of digits from the decimal to the least significant digit, is represented as s in the data type
Indicates that the attribute was used to construct the model. Some attributes may be eliminated by transformations or algorithmic processing. The *
Whether or not the attribute is a target. The value can be either
If the attribute is a target, and it has undergone transformations for manipulation by the algorithm, the description in
The query in Example 3-2 returns information about the data attributes of the model
T_SVM_CLAS_SAMPLE, an SVM model generated by one of the Data Mining sample programs. The query returns the name and data type of each of the data attributes in the model signature, whether the attribute is used as a numerical or as a categorical, and whether or not the attribute is a target.
Example 3-2 ALL_MINING_MODEL_ATTRIBUTES
SQL> select model_name, attribute_name, attribute_type, data_type, target from user_mining_model_attributes where model_name = 'T_SVM_CLAS_SAMPLE'; MODEL_NAME ATTRIBUTE_NAME ATTRIBUTE_TYPE DATA_TYPE TARGET ------------------- --------------------- --------------- ----------- ------ T_SVM_CLAS_SAMPLE COMMENTS NUMERICAL NESTED TABLE NO T_SVM_CLAS_SAMPLE AGE NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE CUST_MARITAL_STATUS CATEGORICAL VARCHAR2 NO T_SVM_CLAS_SAMPLE COUNTRY_NAME CATEGORICAL VARCHAR2 NO T_SVM_CLAS_SAMPLE CUST_INCOME_LEVEL CATEGORICAL VARCHAR2 NO T_SVM_CLAS_SAMPLE EDUCATION CATEGORICAL VARCHAR2 NO T_SVM_CLAS_SAMPLE OCCUPATION CATEGORICAL VARCHAR2 NO T_SVM_CLAS_SAMPLE HOUSEHOLD_SIZE CATEGORICAL VARCHAR2 NO T_SVM_CLAS_SAMPLE YRS_RESIDENCE NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE BULK_PACK_DISKETTES NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE FLAT_PANEL_MONITOR NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE HOME_THEATER_PACKAGE NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE BOOKKEEPING_APPLICATION NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE PRINTER_SUPPLIES NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE Y_BOX_GAMES NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE OS_DOC_SET_KANJI NUMERICAL NUMBER NO T_SVM_CLAS_SAMPLE CUST_GENDER CATEGORICAL CHAR NO T_SVM_CLAS_SAMPLE AFFINITY_CARD NUMERICAL NUMBER YES
The model attribute name consists of two parts: a column name, and a subcolumn name.
column_name component is the name of the data attribute. It is present in all model attribute names. Nested attributes also have a
subcolumn_name component as shown in Example 3-3.
Example 3-3 Model Attributes Derived from a Nested Column
The nested column
SALESPROD has three rows.
The name of the data attribute is
SALESPROD. Its associated model attributes are:
Model details reveal information about model attributes and their treatment by the algorithm. There is a separate
GET_MODEL_DETAILS routine for each algorithm.
Transformation and reverse transformation expressions are associated with model attributes. The transformations are applied to the model for algorithmic processing. The reverse transformations are applied for model details. The information returned to the user by
GET_MODEL_DETAILS is expressed in the form of the original data attributes, or as close to it as possible.
Reverse transformations are also applied to the target when a supervised model is scored. Reverse transformations support model transparency. Transparency is discussed in Oracle Data Mining Concepts.
Example 3-4 shows the definition of the
GET_MODEL_DETAILS function for an Attribute Importance model. The
PIPELINED keyword instructs Oracle Database to return the rows as single values instead of returning all the rows as a single value.
Example 3-4 Model Details for an Attribute Importance Model
The syntax of the
GET_MODEL_DETAILS function for Attribute Importance models is shown as follows.
DBMS_DATA_MINING.GET_MODEL_DETAILS_AI ( model_name VARCHAR2) RETURN DM_RANKED_ATTRIBUTES PIPELINED;
The function returns
DM_RANKED_ATTRIBUTES, a virtual table. The columns are the model details. There is one row for each model attribute in the specified model. The columns are described as follows.
(attribute_name VARCHAR2(4000), attribute_subname VARCHAR2(4000), importance_value NUMBER, rank NUMBER(38))
Oracle Data Mining requires a case table in single-record case format, with each record in a separate row. What if some or all of your data is in multi-record case format, with each record in several rows? What if you want one attribute to represent a series or collection of values, such as a student's test scores or the products purchased by a customer?
This kind of one-to-many relationship is usually implemented as a join between tables. For example, you might join your customer table to a sales table and thus associate a list of products purchased with each customer.
Oracle Data Mining supports dimensioned data through nested columns. To include dimensioned data in your case table, create a view and cast the joined data to one of the Data Mining nested table types. Each row in the nested column consists of an attribute name/value pair. Oracle Data Mining internally processes each nested row as a separate attribute.
See Also:Sample code for converting to a nested table in "Example: Creating a Nested Column for Mining".
The algorithms that support nested data are listed in Table 3-2
Table 3-2 Oracle Data Mining Algorithms that Support Nested Data
|Mining Function
association rules
classification and regression
attribute importance
Naive Bayes
feature extraction
classification, regression, and anomaly detection
Oracle Database supports user-defined data types that make it possible to model real-world entities as objects in the database. Collection types are object data types for modeling multi-valued attributes. Nested tables are collection types. Nested tables can be used anywhere that other data types can be used. You can learn more about collection types in Oracle Database Object-Relational Developer's Guide.
Oracle Data Mining supports two nested object types: one for numerical attributes, the other for categorical attributes.
DM_NESTED_NUMERICALS object type is a nested table of numerical attributes. Each row is a single
The nested numerical attributes (rows) are described as follows.
SQL> describe
Name Null? Type
--------------------------------yH��--------- -------- ----------------------------
The collection of numerical attributes (table) is described as follows.
SQL> describe
Name Null? Type
----------------------------------------- -------- ----------------------------
DM_NESTED_CATEGORICALS object type is a nested table of categorical attributes. Each row is a single
The nested categorical attributes (rows) are described as follows.
SQL> describe
Name Null? Type
----------------------------------------- -------- ----------------------------
The collection of categorical attributes (table) is described as follows.
SQL> describe
Name Null? Type
----------------------------------------- -------- ----------------------------
Example 3-5 shows data from a view of a sales table. It includes sales for three of the many products sold in four regions. This data is not suitable for mining at the product level because sales for each case (product), is stored in several rows.
Example 3-5 Product Sales per Region in Multi-Record Case Format
PRODUCT REGION SALES ------- -------- ---------- Prod1 NE 556432 Prod2 NE 670155 Prod3 NE 3111 . . Prod1 NW 90887 Prod2 NW 100999 Prod3 NW 750437 . . Prod1 SE 82153 Prod2 SE 57322 Prod3 SE 28938 . . Prod1 SW 3297551 Prod2 SW 4972019 Prod3 SW 884923 . .
Example 3-6 shows how this data could be transformed for mining. The case ID column would be
SALES_PER_REGION, a nested column of type
DM_NESTED_NUMERICALS, would be a data attribute. This table is suitable for mining, because the information for each case is stored in a single row.
Example 3-6 Product Sales per Region in Single-Record Case Format
PRODUCT SALES_PER_REGION (ATTRIBUTE_NAME, VALUE) ------ -------------------------- Prod1 ('NE' , 556432) ('NW' , 90887) ('SE' , 82153) ('SW' , 3297551) Prod2 ('NE' , 670155) ('NW' , 100999) ('SE' , 57322) ('SW' , 4972019) Prod3 ('NE' , 3111) ('NW' , 750437) ('SE' , 28938) ('SW' , 884923) . .
Oracle Data Mining treats each nested row as a separate model attribute, as shown in Example 3-7. (Note that the presentation in this example is conceptual only. The data is not actually pivoted before being processed.)
Example 3-7 Model Attributes Derived From SALES_PER_REGION
PRODUCT SALES_PER_REGION.NE SALES_PER_REGION.NW SALES_PER_REGION.SE SALES_PER_REGION.SW ------- ------------------ ------------------- ------------------ ------------------- Prod1 556432 90887 82153 3297551 Prod2 670155 100999 57322 4972019 Prod3 3111 750437 28938 884923 . .
Example 3-8 shows how to define a nested column for data mining. This example uses transactional market basket data.
Example 3-8 Convert to a Nested Column
The view
SALES_TRANS_CUST provides a list of transaction IDs to identify each market basket and a list of the products in each basket.
SQL> describe sales_trans_cust Name Null? Type ----------------------------------------------------- -------- ---------------- TRANS_ID NOT NULL NUMBER PROD_NAME NOT NULL VARCHAR2(50) QUANTITY NUMBER
The following SQL statement transforms this data to a column of type
DM_NESTED_NUMERICALS in a view called
SALES_TRANS_CUST_NESTED. This view can be used as a case table for mining.
SQL> CREATE VIEW sales_trans_cust_nested AS SELECT trans_id, CAST(COLLECT(
DM_NESTED_NUMERICAL( prod_name, quantity)) AS
DM_NESTED_NUMERICALS) custprods FROM sales_trans_cust GROUP BY trans_id;
This query returns two rows from the transformed data.
SQL> select * from sales_trans_cust_nested where trans_id < 101000 and trans_id > 100997; TRANS_ID CUSTPRODS(ATTRIBUTE_NAME, VALUE) ------- ------------------------------------------------ 100998 DM_NESTED_NUMERICALS (DM_NESTED_NUMERICAL('O/S Documentation Set - English', 1) 100999 DM_NESTED_NUMERICALS (DM_NESTED_NUMERICAL('CD-RW, High Speed Pack of 5', 2), DM_NESTED_NUMERICAL('External 8X CD-ROM', 1), DM_NESTED_NUMERICAL('SIMM- 16MB PCMCIAII card', 1))
Market basket data identifies the items sold in a set of baskets or transactions. Oracle Data Mining provides the association mining function for market basket analysis.
Association models use the Apriori algorithm to generate association rules that describe how items tend to be purchased in groups. For example, an association rule might assert with 65% confidence that 80% of the people who buy peanut butter also buy jelly.
Market basket data is usually transactional. In transactional data, a case is a transaction and the data for a transaction is stored in multiple rows. Oracle Data Mining can only process transactional data if it is transformed to a nested table.
The Apriori algorithm assumes that the data is transactional and that it has many missing values. Apriori interprets all missing values as sparse data, and it has its own native mechanisms for handling sparse data.
See Also:"Missing Data".
Oracle Data Mining distinguishes between sparse data and data that contains random missing values. The latter means that some attribute values are unknown. Sparse data, on the other hand, contains values that are assumed to be known, although they are not represented in the data.
A typical example of sparse data is market basket data. Out of hundreds or thousands of available items, only a few are present in an individual case (the basket or transaction). All the item values are known, but they are not all included in the basket. Present values may have a quantity, while the items that are not represented are sparse (with a known quantity of zero).
Oracle Data Mining interprets missing data as follows:
Missing — Missing values in columns with a simple data type (not nested) are assumed to be missing at random.
Sparse — Missing values in nested columns indicate sparsity.
The examples in this section illustrate how Oracle Data Mining identifies data as either sparse or missing at random.
A sales table contains point-of-sale data for a group of products, sold in several stores to different customers over a period of time. A particular customer will only have bought some of the products. Those products that a customer did not buy will not appear as rows in the sales table.
If you were to figure out the amount of money a customer has spent for each product, the unpurchased products would have an inferred amount of zero. The value is not random or unknown; it is zero, even though no row appears in the table.
Note that the sales data is dimensioned (by product, stores, customers, and time) and would be represented as nested data for mining.
Since missing values in a nested column will always indicate sparsity, you should make sure that this interpretation is appropriate for the data that you wish to mine. For example, when trying to mine a multi-record case data set containing users' movie ratings of a large movie database, the missing ratings would be unknown (missing at random), but Oracle Data Mining would treat the data as sparse and infer a rating of zero for the missing value.
A table of customer data contains demographic data about customers. The case ID column is the customer ID. The attributes are age, education, profession, gender, house-hold size, and so on. Not all the data may be available for each customer. Any missing values are considered to be missing at random. For example, if the age of customer 1 and the profession of customer 2 are not present in the data, that information is simply unknown. It does not indicate sparsity.
Note that the customer data is not dimensioned. There is a one-to-one mapping between the case and each of its attributes. None of the attributes are nested.
Missing value treatment depends on the algorithm and on the nature of the data (categorical or numerical, sparse or missing at random). Missing value treatment is summarized in Table 3-3.
Note:Oracle Data Mining performs the same missing value treatment whether or not Automatic Data Preparation is being used.
Table 3-3 Missing Value Treatment by Algorithm
|Missing Data
|SVM, NMF, k-Means, GLM
NUMERICAL missing at random
Oracle Data Mining replaces missing numerical values with the mean.
The algorithm handles missing values naturally as missing at random.
The algorithm interprets all missing data as sparse.
CATEGORICAL missing at random
Oracle Data Mining replaces missing categorical values with the mode.
The algorithm handles missing values naturally as missing random.
The algorithm interprets all missing data as sparse.
NUMERICAL sparse
Oracle Data Mining replaces sparse numerical data with zeros.
DT and O-Cluster do not support nested data, and therefore do not support sparse data. NB and MDL replace sparse numerical data with zeros.
The algorithm handles sparse data.
CATEGORICAL sparse
Oracle Data Mining replaces sparse categorical data with zero vectors.
DT and O-Cluster do not support nested data, and therefore do not support sparse data. NB and MDL replace sparse categorical data with the special value
The algorithm handles sparse data.
If you want Oracle Data Mining to treat missing data as sparse instead of missing at random or missing at random instead of sparse, transform it before building the model.
If you want missing values to be treated as sparse, but Oracle Data Mining would interpret them as missing at random, you can use a SQL function like NVL to replace the nulls with a value such as "NA". Oracle Data Mining will not perform missing value treatment if there is a specified value. See Oracle Database SQL Language Reference
If you want missing nested attributes to be treated as missing at random, you can transform the nested rows into physical attributes in separate columns — as long as the case table stays within the 1000 column limitation imposed by the Database. Fill in all of the possible attribute names, and specify them as null.
This chapter explains how to create data mining models and retrieve model details.
Note:This chapter assumes a basic understanding of mining functions and algorithms, as described in Oracle Data Mining Concepts.
This chapter contains the following topics:
The general steps involved in creating a data mining model are summarized as follows:
Prepare the data. (See Chapter 3.)
Optionally, specify model settings. (See "Model Settings".)
Create the model. (See "Creating a Model".)
View model details. (See "Model Details".)
Test the model. (See Oracle Data Mining Concepts for information about test metrics for classification and regression.)
Evaluate the model with questions like: How accurate is the model? If there are rules associated with the model, what is their confidence and support? How well does the model address the business question?
Note:To better understand this process, you can look at the source code of the sample data mining programs provided with Oracle Database. See "Sample Mining Models".
See Also:Oracle Data Mining Concepts for more information about the process of building a model
Numerous settings are available for configuring data mining models at build time. To specify settings, create a settings table and pass it to the model creation process. A settings table is optional, because all settings have default values.
Model settings are documented in Oracle Database PL/SQL Packages and Types Reference. If you are using the HTML version of Oracle Data Mining Application Developer's Guide, the links in Table 5-1 will take you directly to the documentation for each type of model setting.
Table 5-1 Model Settings
Modify the mining function
Modify the algorithm
Set global model characteristics
Enable or disable Automatic Data Preparation
A settings table must have the columns shown in Table 5-2.
Table 5-2 Settings Table Required Columns
|Column Name
|Data Type
The values inserted into the
setting_name column are one or more of several constants defined in the
DBMS_DATA_MINING package. Depending on what the setting name denotes, the value for the
setting_value column can be a predefined constant or the actual numerical value corresponding to the setting itself. The
setting_value column is defined to be
VARCHAR2. You can explicitly cast numerical inputs to string using the
TO_CHAR() function, or you can rely on the implicit type conversion provided by the Database.
Example 5-1 creates a settings table for an SVM classification model. Since SVM is not the default classifier, the
ALGO_NAME setting is used to specify the algorithm. Setting the
SVMS_KERNEL_FUNCTION to
SVMS_LINEAR causes the model to be built with a linear kernel. If you do not specify the kernel function, the algorithm chooses the kernel based on the number of attributes in the data.
Example 5-1 Create a Settings Table
CREATE TABLE svmc_sh_sample_settings ( setting_name VARCHAR2(30), setting_value VARCHAR2(4000)); BEGIN INSERT INTO svmc_sh_sample_settings (setting_name, setting_value) VALUES (dbms_data_mining.algo_name, dbms_data_mining.algo_support_vector_machines); INSERT INTO svmc_sh_sample_settings (setting_name, setting_value) VALUES (dbms_data_mining.svms_kernel_function, dbms_data_mining.svms_linear); COMMIT; END; /
ALGO_NAME setting specifies the algorithm for a model. If you wish to use the default algorithm for a particular mining function, or if there is only one algorithm available for the mining function, you do not need to specify the
ALGO_NAME setting.
Table 5-3 Data Mining Algorithms
|ALGO_NAME Value
|Mining Model Function
Non-Negative Matrix Factorization
regression, classification, and anomaly detection (classification with no target)
CLAS_COST_TABLE_NAME setting specifies the name of a cost matrix table to be used in building a Decision Tree model. A cost matrix biases a classification model to minimize costly misclassifications. The cost matrix table must have the columns shown in Table 5-4.
Table 5-4 Cost Matrix Table Required Columns
|Column Name
|Data Type
Decision Tree is the only algorithm that supports a cost matrix at build time. However, you can create a cost matrix and associate it with any classification model for scoring.
If you want to use costs for scoring, create a table with the columns shown in Table 5-4, and use the
DBMS_DATA_MINING.ADD_COST_MATRIX procedure to add the cost matrix table to the model. You can also specify a cost matrix inline when invoking a
PREDICTION function.
See Also:Oracle Data Mining Concepts for information about costs
CLAS_PRIORS_TABLE_NAME setting specifies the name of a table of prior probabilities to be used in building a Naive Bayes model. Prior probabilities can be used to offset differences in distribution between the build data and the actual population. The priors table must have the columns shown in Table 5-5.
Table 5-5 Priors Table Required Columns
|Column Name
|Data Type
SVM classification uses the information in the priors table as class weights.
See Also:Oracle Data Mining Concepts for information about priors
CLAS_WEIGHTS_TABLE_NAME setting specifies the name of a table of class weights to be used to bias a GLM model to favor higher weighted classes. The weights table must have the columns shown in Table 5-6.
Table 5-6 Class Weights Table Required Columns
|Column Name
|Data Type
See Also:Oracle Data Mining Concepts for information about class weights
Information about mining model settings can be obtained from the data dictionary view
ALL/USER/DBA_MINING_MODEL_SETTINGS. When used with the
ALL prefix, this view returns information about the settings for the models accessible to the current user. When used with the
USER prefix, it returns information about the settings for the models in the user's schema. The
DBA prefix is only available for DBAs.
The columns of
ALL_MINING_MODEL_SETTINGS are described as follows and explained in Table 5-7.
SQL> describe all_mining_model_settings Name Null? Type ----------------------------------------- -------- ---------------------------- OWNER NOT NULL VARCHAR2(30) MODEL_NAME NOT NULL VARCHAR2(30) SETTING_NAME NOT NULL VARCHAR2(30) SETTING_VALUE VARCHAR2(4000) SETTING_TYPE VARCHAR2(7)
Table 5-7 ALL_MINING_MODEL_SETTINGS
Owner of the mining model
Name of the mining model
Name of the setting
Value of the setting
'INPUT' if the value is specified by a user; 'DEFAULT' if the value is system-generated
The following query lists the settings for the SVM classification model
SVMC_SH_CLAS_SAMPLE. The
CLAS_PRIORS_TABLE_NAME, and
SVMS_KERNEL_FUNCTION settings are user-specified. These settings have been specified in a settings table for the model.
Example 5-2 ALL_MINING_MODEL_SETTINGS
SQL> COLUMN setting_value FORMAT A25 SQL> SELECT setting_name, setting_value, setting_type FROM all_mining_model_settings WHERE model_name in 'SVMC_SH_CLAS_SAMPLE'; SETTING_NAME SETTING_VALUE SETTING_TYPE ------------------------------ ------------------------- ------------ ALGO_NAME ALGO_SUPPORT_VECTOR_MACHINES INPUT SVMS_ACTIVE_LEARNING SVMS_AL_ENABLE DEFAULT CLAS_PRIORS_TABLE_NAME svmc_sh_sample_priors INPUT PREP_AUTO OFF DEFAULT SVMS_COMPLEXITY_FACTOR 0.244212 DEFAULT SVMS_KERNEL_FUNCTION SVMS_LINEAR INPUT SVMS_CONV_TOLERANCE .001 DEFAULT
Note:Some model settings are determined by the algorithm if not specified in a settings table. You can find the system-generated setting values by querying the
ALL_MINING_MODEL_SETTINGS view.
See Also:Oracle Database PL/SQL Packages and Types Reference for details about model settings
CREATE_MODEL procedure in the
DBMS_DATA_MINING package creates a mining model with the specified name, mining function, and case table (build data).
DBMS_DATA_MINING.CREATE_MODEL ( model_name IN VARCHAR2, mining_function IN VARCHAR2, data_table_name IN VARCHAR2, case_id_column_name IN VARCHAR2, target_column_name IN VARCHAR2 DEFAULT NULL, settings_table_name IN VARCHAR2 DEFAULT NULL, data_schema_name IN VARCHAR2 DEFAULT NULL, settings_schema_name IN VARCHAR2 DEFAULT NULL, transform_list IN DM_TRANSFORMS DEFAULT NULL;)
See Also:
DBMS_DATA_MINING.CREATE_MODEL in Oracle Database PL/SQL Packages and Types Reference
The mining function is a required argument to the
CREATE_MODEL procedure. A data mining function specifies a class of problems that can be modeled and solved.
Data mining functions implement either supervised or unsupervised learning. Supervised learning uses a set of independent attributes to predict the value of a dependent attribute or target. Unsupervised learning does not distinguish between dependent and independent attributes.
Supervised functions are predictive. Unsupervised functions are descriptive.
You can specify any of the values in Table 5-8 for the mining_function parameter to
Table 5-8 Mining Model Functions
|Mining_Function Value
Association is a descriptive mining function. An association model identifies relationships and the probability of their occurrence within a data set.
Attribute Importance is a predictive mining function. An attribute importance model identifies the relative importance of an attribute in predicting a given outcome.
Attribute Importance models use the Minimal Description Length algorithm.
Classification is a predictive mining function. A classification model uses historical data to predict a categorical target.
Classification models can use: Naive Bayes, Decision Tree, Logistic Regression, or Support Vector Machine algorithms. The default is Naive Bayes.
The classification function can also be used for anomaly detection. In this case, the SVM algorithm with a null target is used (One-Class SVM).
Clustering is a descriptive mining function. A clustering model identifies natural groupings within a data set.
Clustering models can use: k-Means or O-Cluster algorithms. The default is k-Means.
Feature Extraction is a descriptive mining function. A feature extraction model creates an optimized data set on which to base a model.
Feature extraction models use the Non-Negative Matrix Factorization algorithm.
Regression is a predictive mining function. A regression model uses historical data to predict a numerical target.
Regression models can use Support Vector Machine or Linear Regression. The default is Support Vector Machine.
See Also:Oracle Data Mining Concepts for an introduction to mining functions
You can optionally specify a list of transformations to be applied to the build data before it is acted on by the algorithm. You can use the
STACK interface in
DBMS_DATA_MINING_TRANSFORM to build a list of transformation expressions for different attributes, you can specify a single transformation using the
XFORM interface in
DBMS_DATA_MINING_TRANSFORM, or you can write your own SQL expressions.
The transformation list argument to
CREATE_MODEL interacts with the
PREP_AUTO setting, which controls Automatic Data Preparation (ADP):
When ADP is on and you specify a transformation list, your transformations are applied with the automatic transformations and embedded in the model.
When ADP is off and you specify a transformation list, your transformations are applied and embedded in the model, but no system-generated transformations are performed.
When ADP is on and you do not specify a transformation list, the system-generated transformations are applied and embedded in the model.
When ADP is off and you do not specify a transformation list, no transformations are embedded in the model; you must separately prepare the data sets you use for building, testing, and scoring the model. This is the pre-release 11 behavior; it is the default behavior in 11g.
See Also:Oracle Data Mining Concepts for information about Automatic Data Preparation
Model details describe model attributes, rules, and other information about the model. You can invoke a
GET_MODEL_DETAILS function to retrieve model details. A separate
GET_MODEL_DETAILS function exists for each algorithm.
Model details reverse the transformations applied to the attributes, thus enabling the information to be easily understood by a user. You can obtain the transformations embedded in the model by invoking the
GET_MODEL_TRANSFORMATIONS function.
Model details, summarized in Table 5-9, support model transparency.
Table 5-9 Model Details
|Model Details
Association rules and frequent itemsets
The full model with its content and rules
Generalized Linear Models
Attribute-level coefficient and statistics from
For each cluster: statistics and hierarchy information, centroid, attribute histograms, and rules
Ranked importance of each attribute
Conditional probabilities and priors
Non-Negative Matrix Factorization
For each cluster: statistics and hierarchy information, centroid, attribute histograms, and rules
Coefficients for linear models
Mining models are database schema objects. Several system and object privileges, described in "Users and Privileges" in Oracle Data Mining Administrator's Guide, govern data mining activities. Mining models also support SQL AUDIT and SQL COMMENT, as described in "Mining Model Schema Objects" in Oracle Data Mining Administrator's Guide.
Information about mining model objects can be obtained from the data dictionary view
ALL/USER/DBA_MINING_MODELS. When used with the
ALL prefix, this view returns information about the mining models accessible to the current user. When used with the
USER prefix, it returns information about the mining models in the user's schema. The
DBA prefix is only available for DBAs.
The columns of
ALL_MINING_MODELS are described as follows and explained in Table 5-10.
SQL> describe all_mining_models Name Null? Type ----------------------------------------- -------- ---------------------------- OWNER NOT NULL VARCHAR2(30) MODEL_NAME NOT NULL VARCHAR2(30) MINING_FUNCTION VARCHAR2(30) ALGORITHM VARCHAR2(30) CREATION_DATE NOT NULL DATE BUILD_DURATION NUMBER MODEL_SIZE NUMBER COMMENTS VARCHAR2(4000)
Table 5-10 ALL_MINING_MODELS
Owner of the mining model.
Name of the mining model.
The mining model function. See "Mining Functions".
The algorithm used by the mining model. See "Specifying the Algorithm".
The date on which the mining model was created.
The duration of the mining model build process in seconds.
The size of the mining model in megabytes.
Results of a SQL
The query in Example 5-3 returns information about the mining models in the schema
Example 5-3 ALL_MINING_MODELS
SQL> select model_name, mining_function, algorithm, creation_date, build_duration FROM all_mining_models WHERE owner IN 'DMUSER'; MODEL_NAME MINING_FUNCTION ALGORITHM CREATION_DATE BUILD_DURA --------------------- --------------------- --------------------------- ----------------------- AI_SH_SAMPLE ATTRIBUTE_IMPORTANCE MINIMUM_DESCRIPTION_LENGTH 13-JUN-07 1 AR_SH_SAMPLE ASSOCIATION_RULES APRIORI_ASSOCIATION_RULES 13-JUN-07 5 DT_SH_CLAS_SAMPLE CLASSIFICATION DECISION_TREE 13-JUN-07 4 KM_SH_CLUS_SAMPLE CLUSTERING KMEANS 13-JUN-07 7 NB_SH_CLAS_SAMPLE CLASSIFICATION NAIVE_BAYES 13-JUN-07 3 OC_SH_CLUS_SAMPLE CLUSTERING O_CLUSTER 13-JUN-07 14 NMF_SH_SAMPLE FEATURE_EXTRACTION NONNEGATIVE_MATRIX_FACTOR 13-JUN-07 2 SVMC_SH_CLAS_SAMPLE CLASSIFICATION SUPPORT_VECTOR_MACHINES 13-JUN-07 4 GLMR_SH_REGR_SAMPLE REGRESSION GENERALIZED_LINEAR_MODEL 13-JUN-07 3 GLMC_SH_CLAS_SAMPLE CLASSIFICATION GENERALIZED_LINEAR_MODEL 13-JUN-07 3 SVMR_SH_REGR_SAMPLE REGRESSION SUPPORT_VECTOR_MACHINES 13-JUN-07 7 SVMO_SH_CLAS_SAMPLE CLASSIFICATION SUPPORT_VECTOR_MACHINES 13-JUN-07 3 T_SVM_CLAS_SAMPLE CLASSIFICATION SUPPORT_VECTOR_MACHINES 13-JUN-07 8 T_NMF_SAMPLE FEATURE_EXTRACTION NONNEGATIVE_MATRIX_FACTOR 13-JUN-07 7
You need the
CREATE MINING MODEL privilege to create models in your own schema. You can perform any operation on models that you own. This includes applying the model, adding a cost matrix, renaming the model, and dropping the model.
You can perform specific operations on mining models in other schemas if you have the appropriate system privileges. For example,
CREATE ANY MINING MODEL enables you to create models in other schemas.
SELECT ANY MINING MODEL enables you to apply models that reside in other schemas. You can add comments to models if you have the
COMMENT ANY MINING MODEL privilege.
See Also:Oracle Data Mining Administrator's Guide for details
The models listed in Example 5-3 are created by the Oracle Data Mining sample programs provided with Oracle Database. The sample programs, in PL/SQL and in Java, create mining models that illustrate each of the algorithms supported by Oracle Data Mining.
The sample programs are installed using Oracle Database Companion. Once installed, you can locate them in the
rdbms/demo subdirectory under Oracle Home. You can list the sample PL/SQL data mining programs on a Linux system with commands like these.
> cd $ORACLE_HOME/rdbms/demo > ls dm*.sql
Likewise, you can list the sample Java data mining programs with commands like the following:
> cd $ORACLE_HOME/rdbms/demo > ls dm*.java
See Also:Oracle Data Mining Administrator's Guide to learn how to install, configure, and execute the Data Mining sample programs.