Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIS2502: Review for Exam 3 Aaron Zhi Cheng acheng@temple.edu http://community.mis.temple.edu/zcheng.

Similar presentations


Presentation on theme: "MIS2502: Review for Exam 3 Aaron Zhi Cheng acheng@temple.edu http://community.mis.temple.edu/zcheng."— Presentation transcript:

1 MIS2502: Review for Exam 3 Aaron Zhi Cheng

2 Please arrive 5 minutes early!
Overview Date: Friday 12/7/2018, during class Place: Regular classroom Please arrive 5 minutes early! Multiple-choice and short-answer questions Closed-book, closed-note No computer Remember to bring: A pen or a pencil, And a calculator!

3 Office Hours Wednesday (12/5), 3:50 pm - 4:50pm @Speakman 201F
Thursday afternoon(12/6) @ Speakman 201F (by appointment)

4 Check the Exam 3 Study Guide
Coverage Check the Exam 3 Study Guide Advanced Data Analytics Techniques Using R and RStudio Understanding Descriptive Statistics (Introduction to R) Decision Tree Analysis (Decision Trees in R) Cluster Analysis (Cluster Analysis Using R) Association Rules (Association Rules Using R)

5 Study Materials Lecture notes In-class exercises
Assignments/Video solutions Course recordings

6 How advanced data analytics differ from OLAP analysis
OLAP can tell you what is happening, or what has happened Whatever can be done using Pivot table is not advanced data analytics Sum, average, min, max, time trend… Advanced data analytics can tell you why it is happening, and help predict what will happen Decision Trees Clustering Association Rules

7 When to use which analysis
When to use which analysis? (Decision Trees, Clustering, and Association Rules) When someone gets an A in this class, what other classes do they get an A in? Can we group our website visitors into types based on their online behaviors? What predicts whether a company will go bankrupt? If someone upgrades to an iPhone, do they also buy a new case? How likely is it going to rain tomorrow? Can we identify different product markets based on customer demographics? Association Rules Clustering Decision Trees Association Rules Decision Trees Clustering

8 Using R and RStudio Difference between R and RStudio Packages in R
Why we install packages? Use functions that were not included in the default R installation Are the packages free? Yes 3. Do we need to re-install the package every time when running a script? No 4. Do we need Internet connection to run packages?

9 Using R and RStudio Basic syntax for R, such as: Variable assignment
(e.g. NUM_CLUSTERS <- 5 or NUM_CLUSTERS = 5 ) Identify functions versus variables Functions accept parameters (in parentheses) and return a value Variables are named containers for data e.g., kmeans() is a function Understand the basic and advanced data types Identify how to access a variable (column) from a dataset (data frame) e.g., dataSet$Salary Salary$dataset dataset.salary

10 R Functions Understand the purpose of the following R functions
read.csv(), summary(), describe(), describeBy(), t.test(), rpart(), kmeans(), apriori() you do not required to memorize the complete syntax of these functions

11 Understanding Descriptive Statistics
Histogram Sample (descriptive) statistics: Mean (average), standard deviation, min, max … Simple hypothesis testing (e.g., t-test)

12 Hypothesis Testing Uses p-values to weigh the strength of the evidence
T-test: A small p-value (typically ≤ 0.05) suggests that there is a statistically significant difference in means. > t.test(subset$TaxiOut~subset$Origin); Welch Two Sample t-test data: subset$TaxiOut by subset$Origin t = , df = , p-value < 2.2e-16 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean in group ORD mean in group PHX 2.2𝑒−16=2.2× 10 −16 ≤0.05 So we conclude that the difference is statistically significant More about p-values:

13 Decision Tree Analysis
Outcome variable: Categorical (instead of continuous ones) Interpreting decision tree output Correct classification rate Probability of purchase? Who are most/least likely to buy? Ex// What is the probability of purchase for a 50 year-old female customer?

14 Decision Tree Analysis
What are the pros and cons with a complex tree? Pros: Better accuracy for the training set Cons: hard to interpret, overfitting How would complexity factor affect the tree? COMPLEXITY FACTOR: the reduction in error needed for an additional split to be allowed Smaller COMPLEXITYFACTOR → more complex tree (or more nodes in a tree)

15 Classification Accuracy
Predicted outcome: 1 Observed outcome: 1001 45 190 3764 Total: 5000 Error rate? (190+45) /5000= 4.7% Correct classification rate? (1-4.7%) = 95.3%

16 predicted outcome red yellow blue 200 50 300 observed outcome Total: 1000 Correct classification rate? ( ) /1000= 70% Error rate? (1-70%) = 30%

17 Cluster Analysis K-means clustering algorithm
K: the number of clusters What is a centroid? Interpret output from a cluster analysis

18 Interpret cluster centroids (means) from normalized data
> # Display the cluster means (means for each input variable) > cat("\nCluster Means (centroids):") Cluster Means (centroids): > MyKMeans$centers RegionDensityPercentile MedianHouseholdIncome AverageHouseholdSize For normalized values, “0” is the average value for that variable. For example, look at Cluster 1: average RegionDensityPercentile >0  higher than the population average average MedianHouseholdIncome and AverageHouseholdSize <0  lower than the population average

19 Cohesion and Separation
2 4 How many clusters? 6 What will change if the number of clusters increases? In general, Cohesion ↑ while Separation↓

20 Cohesion and Separation
Recall…. withinss = within-cluster sum of squares errors = within-cluster SSE betweenss = between-cluster sum of squares errors = between-cluster SSE Cohesion Higher withinss = Lower cohesion (BAD) High withinss means that elements within cluster are far away from each other Separation Higher betweenss = Higher separation (GOOD) High betweenss means that different clusters are far away from each other We want high cohesion (i.e., low withinss) and high separation (i.e., high betweenss)!

21 Cohesion and Separation
Interpret withinss (cohesion) and betweensss (separation) > # Display withinss (i.e. the within-cluster SSE for each cluster) > cat("\nWithin cluster SSE for each cluster (Cohesion):") Within cluster SSE for each cluster (Cohesion): > MyKMeans$withinss; [1] withinss error (cohesion) Cluster 3 has the highest withinss error (lowest cohesion) > # Display betweenss (i.e. the SSE between clusters) > cat("\nTotal between-cluster SSE (Seperation):") Total between-cluster SSE (Seperation): > MyKMeans$betweenss [1] > # Compute average separation: more clusters = less separation > cat("\Average between-cluster SSE:") Average between-cluster SSE: > MyKMeans$betweenss/NUM_CLUSTER [1] total betweensss error average betweensss error (separation)

22 Association Rules Interpret the output from an association rule analysis Compute support count (𝜎), support (s), confidence, and lift lhs rhs support confidence lift 611 {CCRD,CKING,MMDA,SVG} => {CKCRD} 485 {CCRD,MMDA,SVG} => {CKCRD} 489 {CCRD,CKING,MMDA} => {CKCRD} 265 {CCRD,MMDA} => {CKCRD} 530 {CCRD,MMDA,SVG} => {CKING} 308 {CCRD,MMDA} => {CKING} Confidence: Strength of the association; Measures how often items in Y appear in transactions that contain X c X→Y = s X→Y s(X) These two formulas will be provided But you need to know how to compute support

23 Association Rules What does Lift > 1 mean? Would you take action on such a rule? the occurrence of X  Y together is more likely than what you would expect by random chance (positive association) What about Lift < 1? the occurrence of X  Y together is less likely than what you would expect by random chance (negative association) What about Lift = 1? the occurrence of X  Y together is the same as random chance (no apparent association. X and Y are independent of each other)

24 c X→Y = s X→Y s(X) Is it possible to have high confidence and low lift? Y is a commonly purchased item -> S(Y) is large (2) Is it possible to have low confidence and high lift? Y is a rarely purchased item -> S(Y) is small

25 Rule Support Confidence Lift
Basket Items 1 Coke, Pop-Tarts, Donuts 2 Cheerios, Coke, Donuts, Napkins 3 Waffles, Cheerios, Coke, Napkins 4 Bread, Milk, Coke, Napkins 5 Coffee, Bread, Waffles 6 Coke, Bread, Pop-Tarts 7 Milk, Waffles, Pop-Tarts 8 Coke, Pop-Tarts, Donuts, Napkins Rule Support Confidence Lift {Coke}  {Donuts} 3/8 = 0.375 3/6 = 0.50 ∗0.375 =𝟏.𝟑𝟑 {Coke, Pop-Tarts} {Donuts} 2/8 = 0.25 2/3 = 0.67 ∗0.375 =𝟏.𝟕𝟖 Which rule has the stronger association? Consider: a customer with coke in the shopping cart. a customer with coke and pop-tarts in the shopping cart. Who do you think is more likely to buy donuts? {Coke, Pop-Tarts} {Donuts} has both higher lift and confidence The second one, with a higher lift

26 Compute Support, confidence, and lift
What is the lift for the rule {Potato Chips}  {Krusty-O’s}? Are people who bought Potato Chips more likely than chance to buy Krusty-O’s too? Krusty-O’s Potato Chips No Yes 5000 1000 4000 500 Total: 10500 𝐿𝑖𝑓𝑡= 𝑠(𝑃𝑜𝑡𝑎𝑡𝑜 𝐶ℎ𝑖𝑝𝑠, 𝐾𝑟𝑢𝑠𝑡𝑦𝑂𝑠 𝑠 𝑃𝑜𝑡𝑎𝑡𝑜 𝐶ℎ𝑖𝑝𝑠 ∗𝑠(𝐾𝑟𝑢𝑠𝑡𝑦𝑂𝑠 = ∗ =0.778 They appear in the same basket less often than what you’d expect by chance (i.e., Lift < 1).

27 Thank you & Good luck!


Download ppt "MIS2502: Review for Exam 3 Aaron Zhi Cheng acheng@temple.edu http://community.mis.temple.edu/zcheng."

Similar presentations


Ads by Google