Oracle® Data Mining Concepts 11g Release 2 (11.2) Part Number E12216-03 |
|
|
View PDF |
This chapter introduces the basics you will need to start using Oracle Data Mining.
This chapter includes the following sections:
Oracle Data Mining provides comprehensive, state-of-the-art data mining functionality within Oracle Database.
Oracle Data Mining is implemented in the Oracle Database kernel, and mining models are first class database objects. Oracle Data Mining processes use built-in features of Oracle Database to maximize scalability and make efficient use of system resources.
Data mining within Oracle Database offers many advantages:
No Data Movement. Some data mining products require that the data be exported from a corporate database and converted to a specialized format for mining. With Oracle Data Mining, no data movement or conversion is needed. This makes the entire mining process less complex, time-consuming, and error-prone.
Security. Your data is protected by the extensive security mechanisms of Oracle Database. Moreover, specific database privileges are needed for different data mining activities. Only users with the appropriate privileges can score (apply) mining models.
Data Preparation and Administration. Most data must be cleansed, filtered, normalized, sampled, and transformed in various ways before it can be mined. Up to 80% of the effort in a data mining project is often devoted to data preparation. Oracle Data Mining can automatically manage key steps in the data preparation process. Additionally, Oracle Database provides extensive administrative tools for preparing and managing data.
Ease of Data Refresh. Mining processes within Oracle Database have ready access to refreshed data. Oracle Data Mining can easily deliver mining results based on current data, thereby maximizing its timeliness and relevance.
Oracle Database Analytics. Oracle Database offers many features for advanced analytics and business intelligence. Oracle Data Mining can easily be integrated with other analytical features of the database, such as statistical analysis and OLAP. See "Oracle Data Mining and Oracle Database Analytics".
Oracle Technology Stack. You can take advantage of all aspects of Oracle's technology stack to integrate data mining within a larger framework for business intelligence or scientific inquiry.
Domain Environment. Data mining models have to be built, tested, validated, managed, and deployed in their appropriate application domain environments. Data mining results may need to be post-processed as part of domain specific computations (for example, calculating estimated risks and response probabilities) and then stored into permanent repositories or data warehouses. With Oracle Data Mining, the pre- and post-mining activities can all be accomplished within the same environment.
Application Programming Interfaces. PL/SQL and Java APIs and SQL language operators provide direct access to Oracle Data Mining functionality in Oracle Database.
A basic understanding of data mining functions and algorithms is required for using Oracle Data Mining. This section introduces the concept of data mining functions. Algorithms are introduced in "Data Mining Algorithms".
Each data mining function specifies a class of problems that can be modeled and solved. Data mining functions fall generally into two categories: supervised and unsupervised. Notions of supervised and unsupervised learning are derived from the science of machine learning, which has been called a sub-area of artificial intelligence.
Artificial intelligence refers to the implementation and study of systems that exhibit autonomous intelligence or behavior of their own. Machine learning deals with techniques that enable devices to learn from their own performance and modify their own functioning. Data mining applies machine learning concepts to data.
See Also:
Part II, "Mining Functions" for more details about data mining functionsSupervised learning is also known as directed learning. The learning process is directed by a previously known dependent attribute or target. Directed data mining attempts to explain the behavior of the target as a function of a set of independent attributes or predictors.
Supervised learning generally results in predictive models. This is in contrast to unsupervised learning where the goal is pattern detection.
The building of a supervised model involves training, a process whereby the software analyzes many cases where the target value is already known. In the training process, the model "learns" the logic for making the prediction. For example, a model that seeks to identify the customers who are likely to respond to a promotion must be trained by analyzing the characteristics of many customers who are known to have responded or not responded to a promotion in the past.
Separate data sets are required for building (training) and testing some predictive models. The build data (training data) and test data must have the same column structure. Typically, one large table or view is split into two data sets: one for building the model, and the other for testing the model.
The process of applying the model to test data helps to determine whether the model, built on one chosen sample, is generalizable to other data. In particular, it helps to avoid the phenomenon of overfitting, which can occur when the logic of the model fits the build data too well and therefore has little predictive power.
Apply data, also called scoring data, is the actual population to which a model is applied. For example, you might build a model that identifies the characteristics of customers who frequently buy a certain product. To obtain a list of customers who shop at a certain store and are likely to buy a related product, you might apply the model to the customer data for that store. In this case, the store customer data is the scoring data.
Most supervised learning can be applied to a population of interest. Scoring is the purpose of classification and regression, the principal supervised mining techniques.
Oracle Data Mining does not support the scoring operation for attribute importance, another supervised function. Models of this type are built on a population of interest to obtain information about that population; they cannot be applied to separate data. An attribute importance model returns and ranks the attributes that are most important in predicting a target value.
See Also:
Table 2-1, "Oracle Data Mining Supervised Functions" for more informationUnsupervised learning is non-directed. There is no distinction between dependent and independent attributes. There is no previously-known result to guide the algorithm in building the model.
Unsupervised learning can be used for descriptive purposes. It can also be used to make predictions.
Although unsupervised data mining does not specify a target, most unsupervised learning can be applied to a population of interest. For example, clustering models use descriptive data mining techniques, but they can be applied to classify cases according to their cluster assignments. Anomaly detection, although unsupervised, is typically used to predict whether a data point is typical among a set of cases.
Oracle Data Mining supports the scoring operation for clustering and feature extraction, both unsupervised mining functions. Oracle Data Mining does not support the scoring operation for association rules, another unsupervised function. Association models are built on a population of interest to obtain information about that population; they cannot be applied to separate data. An association model returns rules that explain how items or events are associated with each other. The association rules are returned with statistics that can be used to rank them according to their probability.
Oracle Data Mining supports the supervised data mining functions described in Table 2-1.
Table 2-1 Oracle Data Mining Supervised Functions
Function | Description | Sample Problem |
---|---|---|
Identifies the attributes that are most important in predicting a target attribute |
Given customer response to an affinity card program, find the most significant predictors |
|
Assigns items to discrete classes and predicts the class to which an item belongs |
Given demographic data about a set of customers, predict customer response to an affinity card program |
|
Approximates and forecasts continuous values |
Given demographic and purchasing data about a set of customers, predict customers' age |
Oracle Data Mining supports the unsupervised functions described in Table 2-2.
Table 2-2 Oracle Data Mining Unsupervised Functions
An algorithm is a mathematical procedure for solving a specific kind of problem. Oracle Data Mining supports at least one algorithm for each data mining function. For some functions, you can choose among several algorithms. For example, Oracle Data Mining supports four classification algorithms.
Each data mining model is produced by a specific algorithm. Some data mining problems can best be solved by using more than one algorithm. This necessitates the development of more than one model. For example, you might first use a feature extraction model to create an optimized set of predictors, then a classification model to make a prediction on the results.
Note:
You can be successful at data mining without understanding the inner workings of each algorithm. However, it is important to understand the general characteristics of the algorithms and their suitability for different kinds of applications.See Also:
Part III, "Algorithms" for more details about the algorithms supported by Oracle Data MiningOracle Data Mining supports the supervised data mining algorithms described in Table 2-3. The algorithm abbreviations are used throughout this manual.
Table 2-3 Oracle Data Mining Algorithms for Supervised Functions
Oracle Data Mining supports the unsupervised data mining algorithms described in Table 2-4. The algorithm abbreviations are used throughout this manual.
Table 2-4 Oracle Data Mining Algorithms for Unsupervised Functions
Data for mining must exist within a single table or view. The information for each case (record) must be stored in a separate row.
A unique capability of Oracle Data Mining is its support for dimensioned data (for example, star schemas) through nested table transformations. Additionally, Oracle Data Mining can mine unstructured data.
See Also:
Oracle Data Mining Application Developer's Guide to learn how to construct a table or view for data miningProper preparation of the data is a key factor in any data mining project. The data must be properly cleansed to eliminate inconsistencies and support the needs of the mining application. Additionally, most algorithms require some form of data transformation, such as binning or normalization.
The data mining development process may require several data sets. One data set may needed for building (training) the model; a separate data set may be used for scoring. Classification models should also have a test data set. Each of these data sets must be prepared in exactly the same way.
Oracle Data Mining supports automatic and embedded data transformation, which can significantly reduce the time and effort involved in developing a data mining model. In Automatic Data Preparation (ADP) mode, the model itself transforms the build data according to the requirements of the algorithm. The transformation instructions are embedded in the model and reused whenever the model is applied.
You can choose to add your own transformations to those performed automatically by Oracle Data Mining. These are embedded along with the automatic transformation instructions and reused with them whenever the model is applied. In this case, you only have to specify your transformations once — for the build data. The model itself will transform the data appropriately when it is applied.
Mining models are known as supermodels, because they contain the instructions for their own data preparation.
Oracle Data Mining is an option to the Enterprise Edition of Oracle Database. It includes programmatic interfaces for SQL, PL/SQL, and Java. It also supports a spreadsheet add-in.
Oracle Data Miner is the graphical user interface for Oracle Data Mining. Oracle Data Miner provides wizards that guide you through the data preparation, data mining, model evaluation, and model scoring process. You can use the code generation feature of Oracle Data Miner to automatically generate PL/SQL code for the mining activities that you perform.
You can download Oracle Data Miner from the Oracle Technology Network.
The Oracle Data Mining PL/SQL API is implemented in the following PL/SQL packages:
DBMS_DATA_MINING — Contains routines for building, testing, and applying data mining models.
DBMS_DATA_MINING_TRANSFORM — Contains routines for transforming the data sets prior to building or applying a model. Users are free to use these routines or any other SQL-based method for defining transformations. The routines in DBMS_DATA_MINING_TRANSFORM
are simply provided as a convenience.
Note that user-defined transformations are not required. Most transformations required by a given algorithm can be performed automatically by Oracle Data Mining.
DBMS_PREDICTIVE_ANALYTICS — Contains automated data mining routines for PREDICT
, EXPLAIN
, and PROFILE
operations.
The following example shows the PL/SQL routine for creating an SVM classification model called my_model
. The algorithm is specified in a settings table called my_settings
. The algorithm must be specified as a setting because Naive Bayes, not SVM, is the default classifier.
CREATE TABLE my_settings( setting_name VARCHAR2(30), setting_value VARCHAR2(4000)); BEGIN INSERT INTO my_settings VALUES (dbms_data_mining.algo_name, dbms_data_mining.algo_support_vector_machines); COMMIT; END; / BEGIN DBMS_DATA_MINING.CREATE_MODEL( model_name => 'my_model', mining_function => dbms_data_mining.classification, data_table_name => 'mining_data_build', case_id_column_name => 'cust_id', target_column_name => 'affinity_card', settings_table_name => 'my_settings'); END; /
The Data Mining functions are SQL language operators for the deployment of data mining models. They allow data mining to be easily incorporated into SQL queries, and thus into SQL-based applications.
The following example illustrates the Data Mining PREDICTION_PROBABILITY
operator. The operator applies the classification model nb_sh_clas_sample
to the data set mining_data_apply_v
.
SELECT cust_id, prob FROM (SELECT cust_id, PREDICTION_PROBABILITY (nb_sh_clas_sample, 1 USING *) prob FROM mining_data_apply_v WHERE cust_id < 100011) ORDER BY cust_id;
The SELECT
statement returns ten customers, listed by customer ID, along with the likelihood that they will accept (1) an affinity card.
CUST_ID PROB ---------- ---------- 100001 .025622714 100002 .090424232 100003 .028064789 100004 .048458859 100005 .989335775 100006 .000151844 100007 .05749942 100008 .108750373 100009 .538512886 100010 .186426058
The Oracle Data Mining Java API is an Oracle implementation of the JDM standard Java API for data mining (JSR-73). The Java API is layered on the PL/SQL API, and the two APIs are fully interoperable.
The following code fragment creates a Decision Tree model that models customer affinity card response patterns and applies this model to predict new customers' affinity card responses.
//Step-1: Create connection to a database with the Data Mining option OraConnectionFactory m_dmeConnFactory = new OraConnectionFactory(); ConnectionSpec connSpec = m_dmeConnFactory.getConnectionSpec(); connSpec.setURI("jdbc:oracle:thin:@<hostName>:<port>:<sid>"); connSpec.setName("<user name>"); connSpec.setPassword("password"); m_dmeConn = m_dmeConnFactory.getConnection(connSpec); //Step-2: Create object factories PhysicalDataSetFactory m_pdsFactory = (PhysicalDataSetFactory)m_dmeConn.getFactory( "javax.datamining.data.PhysicalDataSet"); PhysicalAttributeFactory m_paFactory = (PhysicalAttributeFactory)m_dmeConn.getFactory( "javax.datamining.data.PhysicalAttribute"); TreeSettingsFactory m_treeFactory = (TreeSettingsFactory)m_dmeConn.getFactory( "javax.datamining.algorithm.tree.TreeSettings"); ClassificationSettingsFactory m_clasFactory = (ClassificationSettingsFactory)m_dmeConn.getFactory( "javax.datamining.supervised.classification.ClassificationSettings"); BuildTaskFactory m_buildFactory = (BuildTaskFactory)m_dmeConn.getFactory( "javax.datamining.task.BuildTask"); ClassificationApplySettingsFactory m_applySettingsFactory = (ClassificationApplySettingsFactory)m_dmeConn.getFactory( "javax.datamining.supervised.classification.ClassificationApplySettings"); DataSetApplyTaskFactory m_dsApplyFactory = (DataSetApplyTaskFactory)m_dmeConn.getFactory( "javax.datamining.task.apply.DataSetApplyTask"); ClassificationApplySettingsFactory m_applySettingsFactory = (ClassificationApplySettingsFactory)m_dmeConn.getFactory( "javax.datamining.supervised.classification.ClassificationApplySettings"); //Step-3: Create and save model build task input objects // (training data, build settings) //Create & save model input data specification (PhysicalDataSet) PhysicalDataSet buildData = m_pdsFactory.create("MINING_DATA_BUILD_V", false); PhysicalAttribute pa = m_paFactory.create("CUST_ID", AttributeDataType.integerType, PhysicalAttributeRole.caseId); buildData.addAttribute(pa); m_dmeConn.saveObject("treeBuildData_jdm", buildData, true); //Create & save Mining Function Settings ClassificationSettings buildSettings = m_clasFactory.create(); TreeSettings treeAlgo = m_treeFactory.create(); buildSettings.setAlgorithmSettings(treeAlgo); buildSettings.setTargetAttributeName("AFFINITY_CARD"); m_dmeConn.saveObject("treeBuildSettings_jdm", buildSettings, true); //Step-4: Create and save model build task BuildTask buildTask = m_buildFactory.create("treeBuildData_jdm", "treeBuildSettings_jdm", "treeModel_jdm"); m_dmeConn.saveObject("treeBuildTask_jdm", buildTask, true); //Step-5: Create and save model apply task input objects (apply settings) //Create & save PhysicalDataSpecification PhysicalDataSet applyData = m_pdsFactory.create("MINING_DATA_APPLY_V", false); PhysicalAttribute pa = m_paFactory.create("CUST_ID", AttributeDataType.integerType, PhysicalAttributeRole.caseId); applyData.addAttribute(pa); m_dmeConn.saveObject("treeApplyData_jdm", applyData, true); //Create & save ClassificationApplySettings ClassificationApplySettings clasAS = m_applySettingsFactory.create(); //Step-6: Create and save model apply task with build task as dependent DataSetApplyTask applyTask = m_dsApplyFactory.create("treeApplyData_jdm", "treeModel_jdm", "treeApplySettings_jdm", "TREE_APPLY_OUTPUT_JDM"); ((OraTask)applyTask).addDependency("treeBuildTask_jdm"); m_dmeConn.saveObject("treeApplyTask_jdm", applyTask, true); //Step-7: Execute build task which executes build task and then after // successful completion triggers the execution of its dependent // task(s). In this example, there is only one dependent task. m_dmeConn.execute("treeBuildTask_jdm");
Predictive Analytics automates the data mining process with routines for PREDICT
, EXPLAIN
, and PROFILE
. The Oracle Spreadsheet Add-In for Predictive Analytics implements these routines for Microsoft Excel.You can use the Spreadsheet Add-In to analyze Excel data or data that resides in an Oracle database.
You can download the Spreadsheet Add-In, including a readme file, from the Oracle Technology Network.
Oracle Data Mining documentation is included in the Oracle Database online documentation library. Four manuals are dedicated to Oracle Data Mining. SQL and PL/SQL syntax for Oracle Data Mining is documented in Database manuals.
For your convenience, the Oracle Data Mining and related Oracle Database manuals are listed in Table 2-5.
Table 2-5 Oracle Data Mining Documentation
Document | Description |
---|---|
Overview of mining functions, algorithms, data preparation, predictive analytics, and other special features supported by Oracle Data Mining |
|
How to use the PL/SQL and Java APIs and the SQL operators for Data Mining |
|
How to install and administer a database for Data Mining. How to install and use the demo programs |
|
How to use the Oracle Data Mining Java API syntax (javadoc) |
|
How to use the Oracle Data Mining PL/SQL syntax |
|
How to use the SQL Data Mining function (operator) syntax |
|
How to query data dictionary views to obtain information about mining models, mining model attributes, and mining model settings |
See Also:
Oracle Database online documentation library athttp://www.oracle.com/pls/db111/homepage
The Oracle Technology Network (OTN) is easily accessible and provides a wealth of information. You can visit the Oracle Data Mining home page at:
http://www.oracle.com/technology/products/bi/odm/index.html
This site provides news and discussion forums as well as tools and educational materials for download. On this site, you will find:
Oracle Data Miner, which you can download and install on your personal computer.
Oracle Data Miner Tutorial, which provides a step-wise introduction to the use of Oracle Data Miner
Oracle By Example instructional scenarios using Oracle Data Miner
Online Training for Oracle Data Miner
Oracle Spreadsheet Add-In for Predictive Analytics, which you can download and import into Excel
Frequently Asked Questions (FAQ) about Oracle Data Mining
Demo programs in SQL and Java that illustrate the Oracle Data Mining APIs
Oracle Data Mining discussion forum at http://forums.oracle.com/forums/forum.jspa?forumID=55
Blog on analytics, statistics, and scientific computing in Oracle Database at http://numoraclerecipes.blogspot.com/
Blog on Data Mining and Analytics, with a special focus on Oracle, at http://oracledmt.blogspot.com/
The following books provide an introduction to Oracle Data Mining. Both are based on Oracle Data Mining 10.2.
Java Data Mining: Strategy, Standard, and Practice, (The Morgan Kaufmann Series in Data Management Systems), by Mark F. Hornick, Erik Marcadé, and Sunil Venkayala
Oracle Data Mining: Mining Gold from Your Warehouse, (Oracle In-Focus series), by Dr. Carolyn Hamm
As described in "Data Mining in the Database Kernel", the advantages of database analytics are considerable. When analytical capabilities are implemented where the data is stored, the data does not have to be exported to an external server for analysis. The results of analysis do not need to be imported; they reside in the database where they can be easily accessed, refreshed, and combined with other data.
Along with data mining and predictive analytics, Oracle Database supports a wide array of analytical features. Since these features are part of a common server it is possible to combine them efficiently. The results of analytical processing can be integrated with Oracle Business Intelligence tools such as Oracle Discoverer and Oracle Portal. Taken as a whole, these features make the Oracle Database a powerful platform for developing analytical applications.
The possibilities for combining different analytics are virtually limitless. Example 2-1 shows data mining and text processing within a single SQL query. The query selects all customers who have a high propensity to attrite (> 80% chance), are valuable customers (customer value rating > 90), and have had a recent conversation with customer services regarding a Checking Plus account. The propensity to attrite information is computed using a Data Mining model called tree_model
. The query uses the Oracle Text CONTAINS
operator to search call center notes for references to Checking Plus accounts.
Example 2-1 Combine Oracle Data Mining and Oracle Text in a SQL Query
SELECT A.cust_name, A.contact_info FROM customers A WHERE PREDICTION_PROBABILITY(tree_model, 'attrite' USING A.*) > 0.8 AND A.cust_value > 90 AND A.cust_id IN (SELECT B.cust_id FROM call_center B WHERE B.call_date BETWEEN '01-Jan-2005' AND '30-Jun-2005' AND CONTAINS(B.notes, 'Checking Plus', 1) > 0);
Some of the analytics supported by Oracle Database are described in Table 2-6. Use the links in the Documentation column to find the referenced documentation.
Table 2-6 Overview of Analytics in Oracle Database
Analytical Feature | Description | Documentation |
---|---|---|
Data Mining |
Oracle Data Mining implements complex algorithms that sift through large volumes of data to find hidden information. Data Mining models discover patterns, predict probable outcomes, identify key predictors, and find other kinds of valuable information |
Present document |
Complex data transformations |
Data transformation is a key aspect of analytical applications and ETL (extract, transform, and load). You can use SQL expressions to implement data transformations, or you can use the
|
|
Statistical functions |
Oracle Database provides a long list of SQL statistical functions with support for: hypothesis testing (such as t-test, F-test), correlation computation (such as pearson correlation), cross-tab statistics, and descriptive statistics (such as median and mode). The |
Oracle Database SQL Language Reference and Oracle Database PL/SQL Packages and Types Reference |
Window and analytic SQL functions |
Oracle Database supports analytic and windowing functions for computing cumulative, moving, and centered aggregates. With windowing aggregate functions, you can calculate moving and cumulative versions of |
|
Frequent Itemsets |
The |
Oracle Database PL/SQL Packages and Types Reference |
Linear algebra |
The |
Oracle Database PL/SQL Packages and Types Reference |
OLAP |
Oracle OLAP supports multidimensional analysis and can be used to improve performance of multidimensional queries. Oracle OLAP provides functionality previously found only in specialized OLAP databases. Moving beyond drill-downs and roll-ups, Oracle OLAP also supports time-series analysis, modeling, and forecasting. |
Oracle OLAP User's Guide |
Spatial analytics |
Oracle Spatial provides advanced spatial features to support high-end GIS and LBS solutions. Oracle Spatial's analysis and mining capabilities include functions for binning, detection of regional patterns, spatial correlation, colocation mining, and spatial clustering. Oracle Spatial also includes support for topology and network data models and analytics. The topology data model of Oracle Spatial allows one to work with data about nodes, edges, and faces in a topology. It includes network analysis functions for computing shortest path, minimum cost spanning tree, nearest-neighbors analysis, traveling salesman problem, among others. |
Oracle Spatial Developer's Guide |
Text Mining |
Oracle Text uses standard SQL to index, search, and analyze text and documents stored in the Oracle database, in files, and on the web. It also supports automatic classification and clustering of document collections. Many of these analytical features are layered on top of ODM functionality |
Oracle Text Application Developer's Guide |