Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Data Mining Query Languages


Published on

  • Be the first to comment

  • Be the first to like this

Data Mining Query Languages

  1. 1. Data Mining Query Languages Kristen LeFevre April 19, 2004 With Thanks to Zheng Huang and Lei Chen
  2. 2. Outline <ul><li>Introduce the problem of querying data mining models </li></ul><ul><li>Overview of three different solutions and their contributions </li></ul><ul><li>Topic for Discussion: What would an ideal solution support? </li></ul>
  3. 3. Problem Description <ul><li>You guys are armed with two powerful tools </li></ul><ul><ul><li>Database management systems </li></ul></ul><ul><ul><li>Efficient and effective data mining algorithms and frameworks </li></ul></ul><ul><li>Generally, this work asks: </li></ul><ul><ul><li>“ How can we merge the two?” </li></ul></ul><ul><ul><li>“ How can we integrate data mining more closely with traditional database systems, particularly querying?” </li></ul></ul>
  4. 4. Three Different Answers <ul><li>DMQL: A Data Mining Query Language for Relational Databases (Han et al, Simon Fraser University) </li></ul><ul><li>Integrating Data Mining with SQL Databases: OLE DB for Data Mining (Netz et al, Microsoft) </li></ul><ul><li>MSQL: A Query Language for Database Mining (Imielinski & Virmani, Rutgers University) </li></ul>
  5. 5. Some Common Ground <ul><li>Create and manipulate data mining models through a SQL-based interface (“Command-driven” data mining) </li></ul><ul><li>Abstract away the data mining particulars </li></ul><ul><li>Data mining should be performed on data in the database (should not need to export to a special-purpose environment) </li></ul><ul><li>Approaches differ on what kinds of models should be created, and what operations we should be able to perform </li></ul>
  6. 6. DMQL <ul><li>Commands specify the following: </li></ul><ul><ul><li>The set of data relevant to the data mining task (the training set) </li></ul></ul><ul><ul><li>The kinds of knowledge to be discovered </li></ul></ul><ul><ul><ul><li>Generalized relation </li></ul></ul></ul><ul><ul><ul><li>Characteristic rules </li></ul></ul></ul><ul><ul><ul><li>Discriminant rules </li></ul></ul></ul><ul><ul><ul><li>Classification rules </li></ul></ul></ul><ul><ul><ul><li>Association rules </li></ul></ul></ul>
  7. 7. DMQL <ul><li>Commands Specify the following: </li></ul><ul><ul><li>Background knowledge </li></ul></ul><ul><ul><ul><li>Concept hierarchies based on attribute relationships, etc. </li></ul></ul></ul><ul><ul><li>Various thresholds </li></ul></ul><ul><ul><ul><li>Minimum support, confidence, etc. </li></ul></ul></ul>
  8. 8. DMQL <ul><li>Syntax </li></ul><ul><ul><li>use database <database_name> </li></ul></ul><ul><ul><li>{use hierarchy <hierarchy_name> for <attribute>} </li></ul></ul><ul><ul><li><rule_spec> </li></ul></ul><ul><ul><li>related to <attr_or_agg_list> </li></ul></ul><ul><ul><li>from <relation(s)> </li></ul></ul><ul><ul><li>[where <conditions>] </li></ul></ul><ul><ul><li>[order by <order list>] </li></ul></ul><ul><ul><li>{with [<kinds of>] threshold = <threshold_value> [for <attribute(s)>]} </li></ul></ul>Specify background knowledge Specify rules to be discovered Collect the set of relevant data to mine Specify threshold parameters Relevant attributes or aggregations
  9. 9. DMQL <ul><li>Syntax <rule_spec> </li></ul><ul><li>find classification rules [as <rule_name>] </li></ul><ul><li>[according to <attributes>] </li></ul><ul><li>Find association rules [as <rule_name>] </li></ul><ul><li>generalize data [into <relation_name>] </li></ul><ul><li>others </li></ul>
  10. 10. DMQL <ul><li>use database Hospital </li></ul><ul><li>find association rules as Heart_Health </li></ul><ul><li>related to Salary, Age, Smoker, Heart_Disease </li></ul><ul><li>from Patient_Financial f, Patient_Medical m </li></ul><ul><li>where f.ID = m.ID and m.age >= 18 </li></ul><ul><li>with support threshold = .05 </li></ul><ul><li>with confidence threshold = .7 </li></ul>
  11. 11. DMQL <ul><li>DMQL provides a display in command to view resulting rules, but no advanced way to query them </li></ul><ul><li>Suggests that a GUI interface might aid in the presentation of these results in different forms (charts, graphs, etc.) </li></ul>
  12. 12. MSQL <ul><li>Focus on Association Rules </li></ul><ul><li>Seeks to provide a language both to selectively generate rules, and separately to query the rule base </li></ul><ul><li>Expressive rule generation language, and techniques for optimizing some commands </li></ul>
  13. 13. MSQL <ul><li>Get-Rules and Select-Rules Queries </li></ul><ul><ul><li>Get-Rules operator generates rules over elements of argument class C, which satisfy conditions described in the “where” clause </li></ul></ul><ul><ul><li>[Project Body, Consequent, confidence, support] </li></ul></ul><ul><ul><li>GetRules(C) [as R1] </li></ul></ul><ul><ul><li>[into <rulebase_name>] </li></ul></ul><ul><ul><li>[where <conds>] </li></ul></ul><ul><ul><li>[sql-group-by clause] </li></ul></ul><ul><ul><li>[using-clause] </li></ul></ul>
  14. 14. MSQL <ul><li><conds> may contain a number of conditions, including: </li></ul><ul><ul><li>restrictions on the attributes in the body or consequent </li></ul></ul><ul><ul><ul><li>“ rule.body HAS {(Job = ‘Doctor’}” </li></ul></ul></ul><ul><ul><ul><li>“ rule1.consequent IN rule2.body” </li></ul></ul></ul><ul><ul><ul><li>“ rule.consequent IS {Age = *}” </li></ul></ul></ul><ul><ul><li>pruning conditions (restrict by support, confidence, or size) </li></ul></ul><ul><ul><li>Stratified or correlated subqueries </li></ul></ul>in , has , and i s are rule subset, superset, and equality respectively
  15. 15. MSQL <ul><li>GetRules(Patients) </li></ul><ul><li>where Body has {Age = *} </li></ul><ul><li>and Support > .05 and Confidence > .7 </li></ul><ul><li>and not exists ( GetRules(Patients) </li></ul><ul><li>Support > .05 and Confidence > .7 </li></ul><ul><li>and R2.Body HAS R1.Body) </li></ul>Retrieve all rules with descriptors of the form “Age = x” in the body, except when there is a rule with equal or greater support and confidence with a rule containing a superset of the descriptors in the body
  16. 16. MSQL <ul><li>GetRules(C) R1 </li></ul><ul><li>where <pruning-conds> </li></ul><ul><li>and not exists ( GetRules(C) R2 </li></ul><ul><li>where <same pruning-conds> </li></ul><ul><li>and R2.Body HAS R1.Body) </li></ul>correlated stratified GetRules(C) R1 where <pruning-conds> and consequent is {(X=*)} and consequent in (SelectRules(R2) where consequent is {(X=*)}
  17. 17. MSQL <ul><li>Nested Get-Rules Queries and their optimization </li></ul><ul><ul><li>Stratified (non-corrolated) queries are evaluated “bottom-up.” The subquery is evaluated first, and replaced with its results in the outer query. </li></ul></ul><ul><ul><li>Correlated queries are evaluated either top-down or bottom-up (like “loop-unfolding”), and there are rules for choosing between the two options </li></ul></ul>
  18. 18. MSQL GetRules(Patients) where Body has {Age = *} and Support > .05 and Confidence > .7 and not exists ( GetRules(Patients) Support > .05 and Confidence > .7 and R2.Body HAS R1.Body)
  19. 19. MSQL GetRules(Patients) where Body has {Age = *} and Support > .05 and Confidence > .7 Top-Down Evaluation For each rule produced by the outer, evaluate the inner not exists ( GetRules(Patients) Support > .05 and Confidence > .7 and R2.Body HAS R1.Body)
  20. 20. MSQL not exists ( GetRules(Patients) Support > .05 and Confidence > .7 and R2.Body HAS R1.Body) Bottom-Up Evaluation For each rule produced by the inner, evaluate the outer GetRules(Patients) where Body has {Age = *} and Support > .05 and Confidence > .7
  21. 21. MSQL <ul><li>Choosing between the two </li></ul><ul><ul><li>In general, evaluate the expression with more restrictive conditions first </li></ul></ul><ul><ul><li>Heuristic rules </li></ul></ul><ul><ul><ul><li>Evaluate the query with higher support threshold first </li></ul></ul></ul><ul><ul><ul><li>Next consider confidence threshold </li></ul></ul></ul><ul><ul><ul><li>A (length = x) expression is in general more restrictive than (length > x), which is more restrictive than (length < x) </li></ul></ul></ul><ul><ul><ul><li>“ Body IS (constant expression)” is more restrictive than “Body HAS”, which is more restrictive than “Body IN” </li></ul></ul></ul><ul><ul><ul><li>Next consider “Consequent IN” expressions </li></ul></ul></ul><ul><ul><ul><li>Descriptors of for (A = a) are more restrictive than wildcards such as (A = *) </li></ul></ul></ul>Meant to prevent unconstrained queries from being evaluated first
  22. 22. OLE DB for DM <ul><li>An extension to the OLE DB interface for Microsoft SQL Server </li></ul><ul><li>Seeks to support the following ideas: </li></ul><ul><ul><li>Define a model by specifying the set of attributes to be predicted, the attributes used for the prediction, and the algorithm </li></ul></ul><ul><ul><li>Populate the model using the training data </li></ul></ul><ul><ul><li>Predict attributes for new data using the populated model </li></ul></ul><ul><ul><li>Browse the mining model (not fully addressed because it varies a lot by model type) </li></ul></ul>None of the others seemed to support this
  23. 23. OLE DB for DM <ul><li>Defining a Mining Model </li></ul><ul><ul><li>Identify the set of data attributes to be predicted, the set of attributes to be used for prediction, and the algorithm to be used for building the model </li></ul></ul><ul><li>Populating the Model </li></ul><ul><ul><li>Pull the information into a single rowset using views, and train the model using the data and algorithm specified </li></ul></ul><ul><ul><li>Supports complex objects, so rowset may be hierarchical (see paper for more complex examples) </li></ul></ul>
  24. 24. OLE DB for DM <ul><li>Using the mining model to predict </li></ul><ul><ul><li>Defines a new operator prediction join . A model may be used to make predictions on datasets by taking the prediction join of the mining model and the data set. </li></ul></ul>
  25. 25. OLE DB for DM <ul><li>CREATE MINING MODEL [Heart_Health Prediction] </li></ul><ul><li>[ID] Int Key, </li></ul><ul><li>[Age] Int, </li></ul><ul><li>[Smoker] Int, </li></ul><ul><li>[Salary] Double discretized, </li></ul><ul><li>[HeartAttack] Int PREDICT, %Prediction column </li></ul><ul><li>USING [Decision_Trees_101] </li></ul>Identifies the source columns for the training data, the column to be predicted, and the data mining algorithm.
  26. 26. OLE DB for DM <ul><li>INSERT INTO [Heart_Health Prediction] </li></ul><ul><li>([ID], [Age], [Smoker], [Salary]) </li></ul><ul><li>SELECT [ID], [Age], [Smoker], [Salary] FROM Patient_Medical M, Patient_Financial F </li></ul><ul><li>WHERE M.ID = F.ID </li></ul>The INSERT represents using a tuple for training the model (not actually inserting it into the rowset).
  27. 27. OLE DB for DM <ul><li>SELECT t.[ID], </li></ul><ul><li>[Heart_Health Prediction].[HeartAttack] </li></ul><ul><li>FROM [Heart_Health Prediction] </li></ul><ul><li>PREDICTION JOIN ( </li></ul><ul><li>SELECT [ID], [Age], [Smoker], [Salary] </li></ul><ul><li>FROM Patient_Medical M, Patient_Financial F </li></ul><ul><li>WHERE M.ID = F.ID) as t </li></ul><ul><li>ON [Heart_Health Prediction].Age = t.Age AND [Heath_Health Prediction].Smoker = t.Smoker AND [Heart_Health Prediction].Salary = t.Salary </li></ul>Prediction join connects the model and an actual data table to make predictions
  28. 28. Key Ideas <ul><li>Important to have an API for creating and manipulating data mining models </li></ul><ul><li>The data is already in the DBMS, so it makes sense to do the data mining where the data is </li></ul><ul><li>Applications already use SQL, so a SQL extension seems logical </li></ul>
  29. 29. Key Ideas <ul><li>Need a method for defining data mining models, including algorithm specification, specification of various parameters, and training set specification (DMQL, MSQL, ODBDM) </li></ul><ul><li>Need a method of querying the models (MSQL) </li></ul><ul><li>Need a way of using the data mining model to interact with other data in the database, for purposes such as prediction (ODBDM) </li></ul>
  30. 30. Discussion Topic: What Functionality would and Ideal Solution Support?