MS SQL SERVER: Data mining concepts and dmx


Published on

MS SQL SERVER: Data mining concepts and dmx

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

MS SQL SERVER: Data mining concepts and dmx

  1. 1. Data Mining Concepts<br />
  2. 2. overview<br />History of DMX<br />DMX Introduction<br />DMX objects<br />Query Syntax<br />Prediction <br />
  3. 3. History of DMX<br />DMX was first introduced in the OLE DB for Data Mining specification authored by Microsoft in conjunction with other vendors in 1999.<br />The goal of DMX is to define common concepts and common query expressions for the data mining world.<br />It is similar to what SQL has done for databases.<br />
  4. 4. overview of DMX<br />Data Mining Extensions (DMX) is a query language for Data Mining Models. It consists of: <br /><ul><li>DDL (Data definition Language)</li></ul>The DDL of the DMX is used to create new data mining models and structures, export and import mining structures, copy or transfer data from one mining model to another and delete existing data mining models and mining structures.<br /><ul><li> DML (Data Manipulation Language)</li></ul>The DML of the DMX is used to search and browse data in the data mining models, update the data mining models by insertion and updating of the data and derive predictions using the prediction query.<br />
  5. 5. DMX objects<br />Data Mining Extensions (DMX) is a language that you can use to create and work with data mining models in Microsoft SQL Server Analysis Services.<br />DMX is used to create the structure of new data mining models, to train these models, and to browse, manage, and predict against them.<br />There are two major objects that are used to manifest this transformation:<br /><ul><li>The mining structure
  6. 6. The mining model</li></li></ul><li>The mining structure<br />A mining structure is defined as a list of columns, with their data types and information describing how they should be handled.<br />When a mining structure is processed, it contains a compressed cache or copy of the source data. <br />This cache is used to train any models that are subsequently added to the structure. which can be queried to return its data or the distinct states that exist in any structure column. <br />The cache is only maintained temporarily, and can be dropped at any time.<br />
  7. 7. The mining model<br />A mining model is the object that transforms rows of data into cases and performs the machine learning using a specified data mining algorithm.<br /> A mining model is described as a subset of columns from the structure, how those columns are to be used as attributes along with the algorithm and parameters to perform machine learning on the structure data.<br />Statistics about predictions are available as well, Additionally the learned patterns themselves can be queried to discover what the algorithm found. <br />These patterns are generally referred to as the model content.<br />
  8. 8. Query Syntax<br />DMX statements are used to create, process, delete, copy, browse, and predict against data mining models.<br />The three basic steps for data mining process are:<br /><ul><li>Creation
  9. 9. Prediction
  10. 10. Training</li></li></ul><li>CREATING MINING STRUCTURES:<br />Creating mining structures is similar to creating tables in SQL.<br />Syntax:<br />CREATE [SESSION] MINING STRUCTURE <structure><br /> ( [(<column definition list>)] )<br />StructureA unique name for the structure.<br />column definitionlistA comma-separated list of column definitions<br />
  11. 11. CREATING MINING STRUCTURES:<br />The following example creates a new mining structure called New Mailing.<br />CREATE MINING STRUCTURE [New Mailing]<br /> ( CustomerKey LONG KEY,<br /> Gender TEXT DISCRETE,<br /> [Number Cars Owned] LONG DISCRETE,<br /> [Bike Buyer] LONG DISCRETE )<br />
  12. 12. ALTERING MINING STRUCTURES:<br />Creates a new mining model that is based on an existing mining structure.<br /> When you use the alter structure statement to create a new mining model, the structure must already exist.<br /> Syntax:<br />ALTER MINING STRUCTURE <structure> <br /> ADD MINING MODEL <model> <br /> ( <column definition list> [(<nested column definition list>) [WITH FILTER (<nested filter criteria>)]] ) <br /> USING <algorithm> [(<parameter list>)]<br /> FILTER keyword is used to filter condition. <br />
  13. 13. ALTERING MINING STRUCTURES<br />The following example adds a Naive Bayes mining model to the New Mailing mining structure and limits the maximum number of attribute states to 50.<br /><br />ALTER MINING STRUCTURE [New Mailing] <br /> ADD MINING MODEL [Naive Bayes] <br /> ( CustomerKey, <br /> Gender,<br /> [Number Cars Owned],<br /> [Bike Buyer] PREDICT ) <br /> USING Microsoft_Naive_Bayes (MAXIMUM_STATES = 50)<br />
  14. 14. Data Types and Content types<br />The following table shows the list of data types and content types for mining structure columns:<br />Time Series models.<br />Sequence Clustering models in nested tables.<br />
  15. 15. DROP MINING MODEL <br />Deletes a mining model from the database.<br />Syntax:<br />DROP MINING MODEL <model ><br />ModelA model identifier.<br />Ex: The following sample code drops the mining model NBSample.<br />DROP MINING MODEL [NBSample]<br />
  16. 16. NESTED TABLES<br />Ex: Consider the following case derived from two tables, one table that contains customer information and another table that contains customer purchases. A single customer in the customer table may have multiple purchases in the purchases table, which makes it difficult to describe the data using a single row. <br />Analysis Services provides a unique method for handling these cases, by using nested tables.<br /> The concept of a nested table is demonstrated in the following illustration.<br />
  17. 17. The first table is the parent table has information about customers, and associates a unique identifier for each customer. <br />The second table, the child table, contains purchases for each customer. <br />The purchases in the child table are related back to the parent table by the unique identifier, the CustomerKey column. The third table in the diagram shows the two tables combined.<br />
  18. 18. Prediction<br />Predictionmeansapplying the patterns that were found in the data to estimate unknown information. <br />Examples: of prediction might be predicting if a customer will or will not be good for a loan, estimating a credit score, determining to what cluster a case belongs, or predicting future values of a time series.<br />
  19. 19. Prediction Join<br />Using prediction join in this example we can come to conclusion that:<br />‘‘if the kid is male and class is 5, then the highest scored subject is science.’’<br />
  20. 20. Prediction Join syntax<br />SELECT [TOP <count>] <column references> FROM <mining model><br /> [[NATURAL] PREDICTION JOIN<br /> <source-data><br /> [ ON <mapping clause> ]<br /> [ WHERE <condition clause> ]<br /> [ ORDER BY <order clause> [DESC | ASC] ]]<br />Count  Optional, An integer that specifies how many rows to return.<br />column referencesA comma-separated list of column identifiers an expressions that are derived from the mining model.<br />mining modelA model identifier.<br />source -dataThe source query.<br />mapping clauseOptional, A logical expression that compares columns from the model to columns from the source query.<br />condition clause Optional, A condition to restrict the values that are returned from the column list.<br />order clause Optional, An expression that returns a scalar value.<br />
  21. 21. summary<br />History of DMX<br />DMX Introduction<br />DMX objects<br />Query Syntax<br />Prediction join syntax<br />
  22. 22. Visit more self help tutorials<br />Pick a tutorial of your choice and browse through it at your own pace.<br />The tutorials section is free, self-guiding and will not involve any additional support.<br />Visit us at<br />