Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- MS SQL SERVER:Microsoft neural netw... by DataminingTools Inc 2301 views
- Bayesian classifiers programmed in sql by ingenioustech 1133 views
- Data Mining by Inwmsn Iheang 524 views
- Comparing Classification and Regres... by Auricle Technolog... 38 views
- A Decision Tree Based Classifier fo... by ijsrd.com 233 views
- 3/5/10 Data Mining: Concepts and Te... by Tommy96 2449 views

7,020 views

Published on

MS SQL SERVER: Decision trees algorithm

No Downloads

Total views

7,020

On SlideShare

0

From Embeds

0

Number of Embeds

17

Shares

0

Downloads

0

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Microsoft Decision Trees Algorithm<br />
- 2. Overview<br />Decision Trees Algorithm<br />DMX Queries<br />Data Mining usingDecision Trees<br />Model Content for a Decision Trees Model<br />Decision Tree Parameters<br />Decision Tree Stored Procedures <br />
- 3. Decision Trees Algorithm<br />The Microsoft Decision Trees algorithm is a classification and regression algorithm provided by Microsoft SQL Server Analysis Services for use in predictive modeling of both discrete and continuous attributes.<br />For discrete attributes, the algorithm makes predictions based on the relationships between input columns in a dataset. It uses the values, known as states, of those columns to predict the states of a column that you designate as predictable. <br />For example, in a scenario to predict which customers are likely to purchase a motor bike, if nine out of ten younger customers buy a motor bike, but only two out of ten older customers do so, the algorithm infers that age is a good predictor of the bike purchase. <br />
- 4. Decision Trees Algorithm<br />For continuous attributes, the algorithm uses linear regression to determine where a decision tree splits.<br />If more than one column is set to predictable, or if the input data contains a nested table that is set to predictable, the algorithm builds a separate decision tree for each predictable column.<br />
- 5. DMX Queries<br />Lets understand how to use DMX queries by creating a simple tree model based on the School Plans data set.<br />The table School Plans contains data about 500,000 high school students, including Parent Support, Parent Income, Sex, IQ, and whether or not the student plans to attend School. <br />using the Decision Trees algorithm, you can create a mining model, predicting the School Plans attribute based on the four other attributes.<br />
- 6. DMX Queries(Classification)<br />CREATE MINING STRUCTURE SchoolPlans<br />(ID LONG KEY,<br />Sex TEXT DISCRETE,<br />ParentIncome LONG CONTINUOUS,<br />IQ LONG CONTINUOUS,<br />ParentSupport TEXT DISCRETE,<br />SchoolPlans TEXT DISCRETE<br />)<br />WITH HOLDOUT (10 PERCENT)<br />ALTER MINING STRUCTURE SchoolPlans<br />ADD MINING MODEL SchoolPlan<br />( ID,<br />Sex,<br />ParentIncome,<br />IQ,<br />ParentSupport,<br />SchoolPlans PREDICT<br />)<br />USING Microsoft Decision Trees<br />Model Creation:<br />
- 7. DMX Queries(Classification)<br />INSERT INTO SchoolPlans<br /> (ID, Sex, IQ, ParentSupport,<br /> ParentIncome, SchoolPlans)<br />OPENQUERY(SchoolPlans,<br /> ‘SELECT ID, Sex, IQ, ParentSupport,<br /> ParentIncome, SchoolPlans FROM SchoolPlans’)<br />Training the SchoolPlan Model<br />
- 8. DMX Queries(Classification)<br />SELECT t.ID, SchoolPlans.SchoolPlans,<br /> PredictProbability(SchoolPlans) AS [Probability]<br />FROM SchoolPlans<br /> PREDICTION JOIN<br /> OPENQUERY(SchoolPlans,<br /> ‘SELECT ID, Sex, IQ, ParentSupport, ParentIncome<br /> FROM NewStudents’) AS t<br />ON SchoolPlans.ParentIncome= t.ParentIncome AND<br />SchoolPlans.IQ = t.IQ AND<br />SchoolPlans.Sex= t.Sex AND<br />SchoolPlans.ParentSupport= t.ParentSupport<br />Predicting the SchoolPlan for a new student.<br />This query returns ID, SchoolPlans, and<br />Probability.<br />
- 9. DMX Queries(Classification)<br />SELECT t.ID,<br /> PredictHistogram(SchoolPlans) AS [SchoolPlans]<br /> FROM SchoolPlans<br /> PREDICTION JOIN<br /> OPENQUERY(SchoolPlans,<br /> ‘SELECT ID, Sex, IQ, ParentSupport, ParentIncome<br /> FROM NewStudents’) AS t<br /> ON SchoolPlans.ParentIncome= t.ParentIncome AND<br />SchoolPlans.IQ = t.IQ AND<br />SchoolPlans.Sex= t.Sex AND<br />SchoolPlans.ParentSupport= t.ParentSupportn<br />Query returns the histogram of the SchoolPlans predictions in the form of a nested table.<br />Result of this query is shown in the next slide.<br />
- 10. DMX Queries(Classification)<br />
- 11. DMX Queries (Regression)<br />Regression means predicting continuous variables using linear regression formulas based on regressors that you specify.<br /> ALTER MINING STRUCTURE SchoolPlans<br /> ADD MINING MODEL ParentIncome<br /> ( ID,<br /> Gender,<br /> ParentIncome PREDICT,<br /> IQ REGRESSOR,<br /> ParentEncouragement,<br /> SchoolPlans<br /> )<br /> USING Microsoft Decision Trees<br /> INSERT INTO ParentIncome<br />Creating and training a regression model to<br />Predict ParentIncome using IQ, Sex, ParentSupport, and SchoolPlans. <br />IQ is used as a regressor.<br />
- 12. DMX Queries (Regression)<br /> SELECT t.StudentID, ParentIncome.ParentIncome,<br /> PredictStdev(ParentIncome) AS Deviation<br />FROM ParentIncome<br /> PREDICTION JOIN <br /> OPENQUERY(SchoolPlans,<br /> ‘SELECT ID, Sex, IQ, ParentSupport,<br /> SchoolPlans FROM NewStudents’) AS t<br /> ON ParentIncome.SchoolPlans = t. SchoolPlans AND<br /> ParentIncome.IQ = t.IQ AND<br /> ParentIncome.Sex = t.Sex AND<br /> ParentIncome.ParentSupport = t. ParentSupport<br />Continuous prediction using a decision tree to predict the ParentIncome for new students and the estimated standard deviation for each prediction.<br />
- 13. DMX Queries(Association)<br />CREATE MINING MODEL DanceAssociation<br /> (<br /> ID LONG KEY,<br /> Gender TEXT DISCRETE,<br /> MaritalStatus TEXT DISCRETE,<br /> Shows TABLE PREDICT<br /> (<br /> Show TEXT KEY<br /> )<br /> )<br /> USING Microsoft Decision Trees<br /><ul><li>An example of an associative trees model built on a Dances data set.
- 14. Each Show is considered an attribute with binary states— existing</li></ul> or missing.<br />
- 15. DMX Queries(Association)<br /> INSERT INTO DanceAssociation<br /> ( ID, Gender, MaritalStatus,<br /> Shows (SKIP, Show))<br /> SHAPE<br /> { <br /> OPENQUERY (DanceSurvey,<br /> ‘SELECT ID, Gender, [Marital Status]<br /> FROM Customers ORDER BY ID’)<br /> }<br /> APPEND<br /> (<br /> {OPENQUERY (DanceSurvey,<br /> ‘SELECT ID, Show<br /> FROM Shows ORDER BY ID’)}<br /> RELATE ID TO ID<br /> )AS Shows<br />Training an associative trees model<br />Because the model contains a nested table, the training statement involves<br /> the Shape statement.<br />
- 16. DMX Queries(Association)<br />Training an associative trees model<br />Suppose that there is a married male customer who likes the Michael Jackson’s Show.<br />This query returns the other five Shows this customer is most likely to find appealing.<br />SELECT t.ID,<br />Predict(DanceAssociation.Shows,5, $AdjustedProbability)<br />AS Recommendation<br />FROM<br />DanceAssociation<br />NATURAL PREDICTION JOIN<br />(SELECT ‘101’ AS ID, ‘Male’ AS Gender,<br />‘Married’ AS MaritalStatus,<br />(SELECT ‘Michael Jackson’ AS Show)<br />AS Shows) AS t<br />
- 17. Data Mining usingDecision Trees<br />The most common data mining task for a decision tree is classification i.e. determining whether or not a set of data belongs to a specific type, or class.<br />The principal idea of a decision tree is to split your data recursively into subsets. <br />The process of evaluating all inputs is then repeated on each subset.<br />When this recursive process is completed, a decision tree is formed.<br />
- 18. Data Mining usingDecision Trees<br />Decision trees offer several advantages over other data mining algorithms.<br />Trees are quick to build and easy to interpret. Each node in the tree is clearly labeled in terms of the input attributes, and each path formed from the root to a leaf forms a rule about your target variable. <br />Prediction based on decision trees is efficient.<br />
- 19. Model Content for a Decision Trees Model<br />The top level is the model node. The children of the model node are its tree root nodes. <br />If a tree model contains a single tree, there is only one node in the second level. <br />The nodes of the other levels are either intermediate nodes (or leaf nodes) of the tree. <br />The probabilities of each predictable attribute state are stored in the distribution row sets.<br />
- 20. Model Content for a Decision Trees Model<br />
- 21. Interpreting the Mining Model Content <br />A decision trees model has a single parent node that represents the model and its metadata underneath which are independent trees that represent the predictable attributes that you select. <br />For example, if you set up your decision tree model to predict whether customers will purchase something, and provide inputs for gender and income, the model would create a single tree for the purchasing attribute, with many branches that divide on conditions related to gender and income.<br />However, if you then add a separate predictable attribute for participation in a customer rewards program, the algorithm will create two separate trees under the parent node. <br />One tree contains the analysis for purchasing, and another tree contains the analysis for the customer rewards program. <br />
- 22. Decision Tree Parameters<br />The tree growth, tree shape, and the input output attribute settings are controlled using these parameters .<br />You can fine-tune your model’s accuracy by adjusting these parameter settings.<br />
- 23. Decision Tree Parameters<br /><ul><li>COMPLEXITY _PENALTYis a floating point number with the range [0,1] which controls how much penalty the algorithm applies to complex trees.</li></ul>When the value of this parameter is set close to 0, there is a lower penalty for the tree growth, and you may see large trees.<br />When its value is set close to 1, the tree growth is penalized heavily, and the resulting trees are relatively small.<br />If there are fewer than 10 input attributes, the value is set to 0.5.<br />if there are more than 100 attributes, the value is set to 0.99. <br />If you have between 10 and 100 input attributes, the value is set to 0.9.<br />
- 24. Decision Tree Parameters<br /><ul><li>MINIMUM _SUPPORT is used to specify the minimum size of each node in a tree.</li></ul>For example, if this value is set to 25, any split that would produce a child node containing less than 25 cases is not accepted. <br />The default value for MINIMUM_SUPPORT is 10.<br /><ul><li>SCORE _METHOD is used to specify the method for determining a split score during tree growth. </li></ul>The three possible values for SCORE METHOD are:<br />SCORE METHOD = 1 use an entropy score for tree growth.<br />SCORE METHOD = 2 use the Bayesian with K2 Prior method, meaning it will add a constant for each state of the predictable attribute in a tree node, regardless of the node level of the tree.<br />SCORE METHOD = 3 use the Bayesian Dirichlet Equivalent with Uniform Prior (BDEU) method.<br />
- 25. Decision Tree Parameters<br /><ul><li>SPLIT METHOD is used to specify the tree shape(binary or bushy)</li></ul>SPLIT METHOD = 1 means the tree is split only in a binary way. <br />SPLIT METHOD = 2 indicates that the tree should always split completely on each attribute. <br />SPLIT METHOD = 3, the default method the decision tree will automatically choose the better of the previous two methods. <br /><ul><li>MAXIMUM_INPUT_ATTRIBUTES is a threshold parameter for feature selection.</li></ul>When the number of input attributes is greater than this parameter value, feature selection is invoked implicitly to select the most significant input attributes.<br />
- 26. Decision Tree Parameters<br /><ul><li>MAXIMUM _0UTPUT_ATTRIBUTESis another threshold parameter for feature selection.</li></ul>When the number of predictable attributes is greater than this parameter value, feature selection is invoked implicitly to select the most significant attributes. <br /><ul><li>FORCE_REGRESSOR allows you to override the regressor selection logic in the decision tree algorithm and always use a specified regressor in the regression equations in regression trees. </li></ul>This parameter is typically used in price elasticity models. <br />For example, suppose that you have a model to predict Sales using Price and other<br /> attributes. If you specify FORCE REGESSOR = Price, you get regression formulas using Price and other significant attributes for each node of the tree.<br />
- 27. Decision Tree Stored Procedures<br />Set of system-stored procedures used in the Decision Tree viewer are:<br /><ul><li>CALL System.GetTreeScores(‘MovieAssociation’)
- 28. CALL System.DTGetNodes(‘MovieAssociation’)
- 29. CALL System.DTGetNodeGraph(‘MovieAssociation’, 60)
- 30. CALL System.DTAddNodes(‘MovieAssociation’,‘36;34’,</li></ul> ‘99;282;20;261;26;201;33;269;30;187’)<br />
- 31. Decision Tree Stored Procedures<br />GetTreeScores is the procedure that the Decision Tree viewer uses to populate the drop-down tree selector. <br />It takes a name of a decision tree model as a parameter and returns a table containing a row for every tree on the model and the following three columns:<br />ATTRIBUTE_NAMEis the name of the tree.<br />NODE_UNIQUE_NAME is the content node representing the root of the tree.<br />MSOLAP_NODE_SCORE is a number representing the amount of information(number of nodes) in the tree.<br />
- 32. Decision Tree Stored Procedures<br />DTGetNodes is used by the decision tree Dependency Network viewer when you click the Add Nodes button.<br /> It returns a row for all potential nodes in the dependency network and has the following two columns:<br />NODE UNIQUE NAME1 is an identifier that is unique for the dependency network.<br />NODE CAPTION is the name of the node.<br />
- 33. Decision Tree Stored Procedures<br />The DTGetNodeGraph procedure returns four columns:<br />When a row has NODE TYPE = 1, it contains a description of the nodes and the remaining three columns have the following interpretation:<br />NODE UNIQUE NAME1 contains a unique identifier for the node.<br />NODE UNIQUE NAME2 contains the node caption.<br />When a row has NODE TYPE = 2, it represents a directed edge in the graph and the remaining columns have these interpretations: <br />NODE UNIQUE NAME1 contains the node name of the starting point of the edge.<br />NODE UNIQUE NAME2 contains the node name of the ending point of the edge.<br />MSOLAP NODE SCORE contains the relative weight of the edge. <br />
- 34. Decision Tree Stored Procedures<br />DTAddNodesallows you to add new nodes to an existing graph. <br />It takes a model name, a semicolon-separated list of the IDs of nodes you want to add to the graph, and a semicolon-separated list of the IDs of nodes already in the graph. <br />This procedure returns a table similar to the NODE TYPE = 2 section of DTGetNodeGraph, but without the NODE TYPE column. <br />The rows in the result set contain all the edges between the added nodes, and all of the edges between the added nodes and the nodes specified as already in the graph.<br />
- 35. Summary<br />Decision Trees Algorithm Overview<br />DMX Queries<br />Data Mining usingDecision Trees<br />Interpreting the Model Content for a Decision Trees Model<br />Decision Tree Parameters<br />Decision Tree Stored Procedures<br />
- 36. 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 www.dataminingtools.net<br />

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment