1
MS4424 Data Mining & Modelling
Lecturer : Dr Iris Yeung Room No : P7509 Tel No : 2788 8566
Email : [email protected]
2
MS4424 Data Mining & Modelling Aims
To introduce the basic concepts of data mining and its applications in various industries with focus on marketing, sales and customer relationship management.
Course Outline
Introduction. Data preparation. Prediction modeling: multiple regressions, logistic regressions, neural networks, decision trees. Cluster analysis and self-organizing maps. Market basket analysis: association analysis and sequence discovery.
3
MS4424 Data Mining & Modelling
Assessment
Coursework : 50% (test, project) Examination : 50% (three hours)
Textbooks
Michael J A Berry and Gordon Linoff, Data Mining Techniques for Marketing, Sales, and Customer Support, John Wiley & Sons, 1997
Michael J A Berry and Gordon Linoff, Mastering Data Mining: The Art and Science of Customer Relationship Management, John Wiley & Sons, 2000
4
Week Content Reading
1 Introduction B Ch 1-5, 6
2-3 Logistic Regression B Ch 7 3-4 Data Preparation B Ch 5 5 Variable Selection B Ch 5
6-7 Decision Tree B Ch 12
8-9 Neural Network B Ch 13
10-11 Cluster Analysis B Ch 10
12 Associations B Ch 8
13 Test
MS4424 Data Mining & Modelling
MS4424 Data Mining & Modelling Introduction
Lecturer : Dr Iris Yeung Room No : P7509 Tel No : 2788 8566
Email : [email protected]
What is Data Mining?
§ Data mining is the exploration and analysis, by automatic or
semiautomatic means, of large quantities of data in order to discover meaningful patterns and rules.
§ Knowledge Discovery in Databases
(KDD)
7
What is Data Mining?
It is an interdisciplinary field bringing together techniques from
§ Statistics
§ Information Science
§ Machine learning
§ Database Technology
§ Visualization
§ Others Disciplines
8
Role of Datawarehouse
9
Why Data Mining Now?
§ The data is being produced at unprecedented rate.
§ The data is being warehoused, which is designed exclusively for data mining.
§ The computer power is affordable.
§ The competitive pressure is strong.
§ Commercial data mining software products have become available.
10
Examples of Using Data Mining
§ Direct Marketing
§ Customer Acquisition
§ Customer Retention
§ Cross-Selling
§ Fraud Detection
§ Forecasting in Financial Markets
11
§ Classification
§ Estimation
§ Prediction
§ Affinity Grouping
§ Clustering
§ Description
What Can Data Mining Do?
12
§ Examine the features of a newly presented object and assign it to one of a predefined set of classes.
§ Examples:
ØClassifying credit applicants as low, medium, or high risk
ØSpotting fraudulent insurance claims
Classification
13
§ Estimation deals with continuously valued outcomes rather than discrete outcomes as compared with classification.
§ Examples:
Øestimate a family’s total household income
Øestimate the lifetime value of a customer Øestimate the value of a piece of real
estate
Estimation
14
§ Same as classification or estimation except that it predicts future behavior
§ Examples:
ØPredicting which customers will leave within the next six months
Prediction
15
§ Determine which things go together.
§ Example: determine what things go together in a shopping cart at the supermarket, hence the term market basket analysis.
§ used to
Øplan arrangement of items on store shelves
Øidentify cross-selling opportunities and to design attractive packages or groupings of product and services.
Affinity Grouping Or Market Basket Analysis
16
§ Segmenting a heterogeneous population into a number of more homogeneous subgroups or clusters.
§ Unlike classification, there are no predefined classes
§ Often precedes some other form of data mining or modeling. For example, first divide the customer base into clusters with similar buying habits, and then ask what kind of promotion works best for each cluster.
Clustering
Description
§
Describe what is going on in a complicated database in a way that increases our understanding of the people, products, or processes§
A good enough description of a behavior will often suggest an explanation for it as well§ Market Basket Analysis (MBA)
§ Memory-Based Reasoning (MBR)
§ Cluster Detection
§ Link Analysis
§ Decision Trees
§ Neural Network
Data Mining Techniques
19
Data Mining using SEMMA
SEMMA stands for
1. Sample – identify input data sets (identify input data, sample from a larger data set, partition data set into training, validation, and test data sets).
2. Explore – explore data set statistically and graphically (plot the data, obtain descriptive statistics, identify important variables, perform association analysis).
3. Modify – prepare the data for analysis (create additional variables or transform existing variables for analysis, identify outliers, impute missing values, modify the way in which variables are used for the analysis, perform cluster analysis, analyze data with SOMs or Kohonen networks.)
20
Data Mining using SEMMA
SEMMA stands for
4. Model – fit a predictive model (model a target variable using a regression model, a decision tree, a neural network, or user- defined model).
5. Assess – compare competing predictive models (build charts plotting percentage of respondents, percentage of
respondents captured, lift charts, profit charts).
21
Getting Started with SAS Enterprise Miner
22
Setting up the initial project and diagram
1. Select File->New->Project
2. Type in name of project (for example, “My project”).
23
Setting up the initial project and diagram
3. Modify the location of the project folder if desired by selecting Browse
4. Select Create. The project opens with an initial untitled diagram.
24
Setting up the initial project and diagram
5. Click on the diagram title and type in a new title if desired (for example, “My First Flow”).
After Selecting Name Final Appearance
25
Identifying the workspace components
1. Observe that the project window opens with the Diagrams tab activated.
Select the Tools tab located to the right of the Diagrams tab in the lower-left portion of the project window. This tab enables you to see all of the tools (or “nodes”) that are available in the Enterprise Miner.
26
Identifying the workspace components
Many of the commonly used tools are shown on the toolbar at the top of the window. If you desire to have additional tools in this toolbar, you can drag them from the window above onto the toolbar.
In addition, you can rearrange the tools on the toolbar by dragging each tool to the desired location on the bar.
27
Identifying the workspace components
2. Select the Reports tab located to the right of the Tools tab. This tab reveals any reports that have been generated for this project. This is a new project, so no reports are currently available.
3. Return to the Tools tab.
28
Sample Nodes
The Input Data Source node read data sources and defines their attributes for later processing by Enterprise Miner.
The Sampling node enables you to take random, stratified random samples, and cluster samples of datasets. Sampling is recommended for extremely large databases because it can significantly decrease model training time. If the sample is sufficiently representative, relationships found in the sample can be expected to generalize to the complete data set. The sampling node writes the sampled observations to an output data set and saves the seed values that are used to generate the random numbers for the samples so that you may replicate the samples.
Sample Nodes
The Data Partition node enables you to partition data sets into training, test, and validation data sets. The training data set is used for preliminary model fitting. The validation data set is used to monitor and tune the model weights during estimation and is also used for model assessment. The test data set is an additional holdout data set and is also used for model assessment. The test data set is an additional holdout data set that you can use for model assessment. This node uses simple random sampling, stratified random sampling, or user-defined partitions to create partitioned data sets.
Explore Nodes
The Distribution Explorer node is a visualization tool that enables you quickly and easily to explore large volumes of data in multidimensional histograms. You can view the distribution of up to three variables at a time with this node. When the variable is binary, nominal, or ordinal, you can select specific values to exclude from the chart. To exclude extreme values for interval variables, you can set a range cutoff. The node also generates summary statistics for the charting variables.
31
Explore Nodes
The Multiplot node is another visualization tool that enables you to explore larger volumes of data graphically.
Unlike the Insight or Distribution Explorer nodes, the Multiplot node automatically creates bar charts and scatter plots for the input and target variables without making several menu or window item selections. The code created by this node can be used to create graphs in a batch environment, whereas the Insight and Distribution explore nodes must be run interactively.
32
Explore Nodes
The Insight node enable you to open a SAS/INSIGHT session. SAS/INSIGHT software is an interactive tool for data exploration and analysis with it you explore data through graphs and analyses that are linked across multiple windows. You can analyze univariate distributions, investigate multivariate distributions, and fit explanatory models using generalized linear models.
The Association node enables you to identify association relationships within the data. For example, if a customer buys a loaf of bread, how likely is the customer to also buy a gallon of milk?
The node also enables you to perform sequence discovery if a time stamp variable (a sequence variable ) is present in the data set.
33
Explore Nodes
The Variable Selection node enables you to evaluate the importance of input variables in predicting or classifying the target variable. To select the important inputs, the node uses either an R-square or a Chi-square selection (tree based) criterion. The R-square criterion enables you to remove variables in hierarchies, remove variables that have large percentages of missing values, and remove class variables that are based on the number of unique values. The variables that are not related to the target are set to a status of rejected. Although rejected variables are passed to subsequent nodes in the process flow diagram, these variables are not used as model inputs by a more detailed modeling node, such as the Neural Network and Tree nodes. You can reassign the input model status to rejected variables.
34
Modify Nodes
The Data Set Attributes node enables you to modify data set attributes, such as data set names, descriptions, and roles. You can also use this node to modify the metadata sample that is associated with a data set and specify target profiles for a target. An example of a useful Data Set Attributes application i s to generate a data set in the SAS Code node and then modify its metadata sample with this node.
35
Modify Nodes
The Transform Variables nodes enables you to transform variables be taking the square root of a variable, by taking the natural logarithm, maximizing the correlation with the target, or normalizing a variable. Additionally, then ode supports user- defined formulas for transformations and provides a visual interface for grouping interval-valued variables into buckets or quantiles. This node also automatically bins interval variables into buckets using a decision tree based algorithm. Transforming variables to similar scale and variability may improve the fit of models and, subsequently, the classification and prediction precision of fitted models.
36
Modify Nodes
The Filter Outliers node enables you to identify and remove outliers from data sets. Checking for outliers is recommended as outliers may greatly affect modeling results and, subsequently, the classification and prediction precision of fitted models.
The Replacement node enables you to impute (fill in )values for observations that have missing values. You can replace missing values for interval variables with the mean, median, midrange, mid-minimum spacing, distribution based replacement, or use a replacement M-estimator such as Tukey’s biweight, Huber’s, or Andrew’s Wave, you can also estimate the replacement values for each interval input by using a tree=based imputation method. Missing values for class variables can be replaced with the most frequently occurring value, distribution- based replacement, tree-based imputation, or a constant.
37
Modify Nodes
The Clustering node enables you to segment your data; that is, it enables you to identify data observations that are similar in some way. Observations that are similar tend to be in the same cluster, and observations that are different tend to be in different clusters. The cluster identifier for each observation can be passed to other nodes for use as an input, ID, or target variable. It also be passed as a group variable that enables you to automatically construct separate models for each group.
38
Modify Nodes
The SOM/Kohonen node generates self-organizing maps, Kohonen network, and vector quantization networks.
Essentially the node performs unsupervised learning in which it attempts to learn the structure of the data. As with the Clustering node, after the network maps have been created, the characteristics can be examined graphically using the results browser. The node provides the analysis results in the form of an interactive map illustrating the characteristics of the clusters. Furthermore, it provides a report indicating the importance of each variable.
39
Model Nodes
The Regression node enables you to fit both linear and logistic regression models to your data. You can use continuous, ordinal, and binary target variables. You can use both continuous and discrete variables as inputs. The node supports the stepwise, forward, and backward selection methods. A point-and click interaction builder enables you to create higher-order modeling terms.
40
Model Nodes
The Tree node enables you to perform multi-way splitting of your database based on nominal, ordinal, and continuous variables.
This is the SAS System implementation of decision trees, which represents a hybrid of the best of CHAID, CART, and C4.5 algorithms. The node supports both automatic and interactive training. When you run the Tree node in automatic mode, it automatically ranks the input variables based on the strength of their contribution to the tree. This ranking may be used to sele ct variables for use in subsequent modeling. In addition, dummy variables can be generated for use in subsequent modeling. You may override any automatic step with the option to define a splitting rule and prune explicit nodes or subtrees. Interactive training enables you to explore and evaluate a large set of trees as you develop them.
Model Nodes
The Neural Network node enables you to construct, train and validate multilayer feed-forward neural networks. By default, the Neural Network node consisting of three neurons. In general, each input is fully connected to the first hidden layer, each hidden layer is fully connected to the next hidden layer, and the last hidden layer is fully connected to the output. The Neural Network node supports may variations of this general form.
The User Defined Model node enables you to generate assessment statistics using predicted values from a model that you built with the SAS Code node (for example, a logistic model using the SAS/STAT LOGISTIC procedure) or the Variable Selection node. The predicted values can also be saved to a SAS
Model Nodes
The Ensemble node enables you to combine models. the usual combination function is the mean. Ensemble models are expected to exhibit greater stability than individual models. they are mo st effective when the individual models exhibit lower correlations.
The node creates three different types of ensembles:
1. Combined model – for example, combining a decision tree and a neural network model. the combination function is the mean of the predicted values.
2. Stratified model – performing group processing over variables values. In this case , there is no combination function because each row in the data set is scored by a single model that is dependent on the value of one or more variables.
3. Bagging/boosting models – performing group processing with resampling. The combination function is the mean of the predicted values. Each observation in the data set is scored by n
43
Assess Nodes
The Assessment node provides a common framework for comparing models and predictions from any of the modeling nodes (Regression, Tree, Neural Network, and User Defined Model nodes). The comparison is based on the expected and actual profits or losses that would result from implementing the model. the node produces the following charts that help to describe the usefulness of the model: lift, profit, return on investment, receiver operating curves, diagnostic charts, and threshold-based charts.
44
Assess Nodes
The Score node enables you to generate and manage predicted values from a trained model. scoring formulas are created for both assessment and prediction. Enterprise Miner generates and manages scoring formulas in the form of SAS DATA step code, which can be used in most SAS environments even without the presence of Enterprise Miner.
The Report node assembles the results from a process flow analysis into an HTML report that can be viewed with your favorite web browser,. Each report contains header information, an image of the process flow diagram, and a separate report for each node in the flow. Reports are managed in the Reports tab of the Project Navigator.
45
Utility Nodes
The Group Processing node enables you to perform group by processing for class variables such as GENDER. You can also use this node to analyze multiple targets, and process the same data source repeatedly by setting the group-processing mode to index.
The Data Mining Database bode enables you to create a data mining database (DMDB) for batch processing. For non- batch processing, DMDBs are automatically created as they are needed.
46
Utility Nodes
The SAS Code node enables you to incorporate new or existing SAS code into process flow diagrams. The ability to write SAS code enables you to include additional SAS system procedures into your data mining analysis. You can also use a SAS DATA step to create customized scoring code., to conditionally process data, and to concatenate or to merge existing data sets. The node provides a macro facility to dynamically reference data sets used for training, validation, testing or scoring and variables, such as input, target, and predict variables. After you run the SAS Code node, the results and the data sets can then be exported for use by subsequent nodes in the diagram.
47
Utility Nodes
The Control Point node enables you to establish a control point to reduce the number of connections that are made in process flow diagrams. For example, suppose three Input Data Source nodes are to be connected to three modeling nodes. If no Control Point node is used, then nine connections are required to connect all of the Input Data Source nodes to all of the modeling nodes. However, if a Control Point node is used, only six connections are required.
The Subdiagram node enables you to group a portion of a process flow diagram into a subdiagram. For complex process flow diagrams, you may want to create subdiagrams to better design and control the process flow.
48
Some general usage rules for nodes
n The Input Data Source cannot be preceded by any other node.
n The Sampling node must be preceded by a node that exports a data set.
n The Assessment node must be preceded by one or more modeling nodes.
n The Score node must be preceded by a node that produces score code. For example, the Modeling nodes produce score code.
n The SAS Code node can be defined in any stage of the process flow diagram. It does not require an input data set defined in the Input Data Source node.
49
Real Case: Telecom Network Fault Prediction
Presented by Dr Yuen in SAS Seminars and Workshop, February 2001
50
Problem Formulation
§ Overview
§ Messages about network performances are generated from transmission stations
§ Messages are examined manually
§ Messages are classified as urgent fault or non - urgent fault
§ To build a model to predict whether a received message signals an urgent fault or not
51
Problem Formulation
§ The Data
§ 5,924 past messages were collected
§ Each message contains 1,082 variables
§ Each message was examine manually
§ The decision "Urgent" or "Non-Urgent" was set as the target variable
§ Urgent case = "True" Non-Urgent case =
"Null"
52
Problem Formulation
§ Distribution of the Target Variable
Null True
Problem Formulation
§ Selection of Cases
§ Use the Sampling node of Enterprise Miner (EM) to select a sample
Variable Selection
§ Using all of the variables in the model is not practical
§ Impractical to examine the associations between the target variable and the other input variables manually
§ The Tree node and the Variable Selection node of Enterprise Miner were employed
55
Variable Selection
§ Some results from Tree1
• A total of 23 variables are selected as input
56
Model Development
§ Data are partitioned into three parts
§ Training (50%)
§ Validation (25%)
§ Testing (25%)
§ Neural Network
57
Model Development
§ Process flow
§ Model Manager
Based on some criteria, choose a neural network model with
the most predictive power 58
Implementing the Model
An incoming signal with predicted Prob(target variable = "True) = p
Class 1 p ≥0.5
Send technician
Class 2 else
Examine the signal manually
Class 3 p ≤0.15
Ignore the signal
•Benefits:Saving in manpower; Faster response time to problems
59
Real Case: Safeway UK
1. Find a certain low- selling yogurt product (rank 209)
2. It was purchased by the top-spending 25% of its customers
3. Identify items that sell well together and adjust in-store promotions, store layout and special offers to generate more profits