Microsoft PowerPoint - Lecture 7-s.pptx Association rule mining and sequential pattern analysis Deakin University CRICOS Provider Code: 00113B Lecture 7 Learning objectives In this lecture… ̶...

Sample Exam Questions


Microsoft PowerPoint - Lecture 7-s.pptx Association rule mining and sequential  pattern analysis Deakin University CRICOS Provider Code: 00113B Lecture 7 Learning objectives In this lecture… ̶ Understanding association rules ̶ Evaluation metrics – Support – Confidence – Lift ̶ Rule generation algorithms – Apriori algorithm – FP‐growth algorithm ̶ Understanding sequential patterns ̶ Applications (ARs, SPs) ̶ A sample exam question Deakin University CRICOS Provider Code: 00113B Slide 2 Quiz! Deakin University CRICOS Provider Code: 00113B A person 35 years of age, shopping at around 6.00pm on a Friday, has  just purchased a pack of nappies on the way home. What would you  think will be the most likely items bought next? ̶ 1: A pack of plastic bags ̶ 2: A DVD of a newly released movie ̶ 3: A soft toy ̶ 4: A bottle of milk ̶ 5: Pair of sunglasses Slide 3 Image source: https://www.maleskin.co.uk/male‐skin‐care‐ assistant Association rules Deakin University CRICOS Provider Code: 00113B What are they? ̶ Are a measure of how strongly two (or more) items co‐occur ̶ Find patterns in the data rather than predicting anything ̶ Are rules extracted from large amounts of data ̶ {Item A} ‐> {Item B}: if A is in the item set, then B will most likely be there too ̶ {Item A and Item B} ‐> {Item C and Item D and Item E} ̶ If a shopper buys milk, then they will most likely buy bread too ̶ If a football team is awarded a penalty, then they will most likely score a goal ̶ If a customer buys one product per quarter, then they will most likely not churn for a year Slide 4 Association rule generic form: {Antecedent(s)} → {Consequent(s)} e.g., if {A,B} Then {C} Association rules Deakin University CRICOS Provider Code: 00113B Containers ̶ Frequent item sets reside in… ̶ Baskets of occurrence (e.g., one transaction, one episode of care, one online session, etc.) ̶ Windows of time (e.g., one day, one quarter [of a game], etc.) ̶ Data may need to be pre‐processed to… ̶ Create containers ̶ Find co‐occurrences in those containers Slide 5 Association rules Deakin University CRICOS Provider Code: 00113B Pre‐processing ̶ Example…field hockey, finding containers Slide 6 Sample data sorted by time Sample data sorted by locations can be within a  time window of  15 seconds  (e.g., windows  shift by 1  second) can be within a  specific  location Association rules Deakin University CRICOS Provider Code: 00113B Pre‐processing ̶ Example…media website, transforming data Slide 7 Sample data set Source: Page 197, R1.Ch6 clickstream converted to binary codes  (items=visits to specific categories) Sample data set Source: Page 198, R1.Ch6 Association rules Deakin University CRICOS Provider Code: 00113B Pre‐processing ̶ Example…media website, transforming data (cont.) ̶ Which rules are likely to be valid? ̶ {News} ‐> {Entertainment} ̶ {News} ‐> {Sports} ̶ {Finance} ‐> {Arts} ̶ {Finance} ‐> {News} ̶ {News, Finance} ‐> {Sports} ̶ {News, Finance} ‐> {Arts} Slide 8 Sample data set Source: Page 198, R1.Ch6 Association rules Deakin University CRICOS Provider Code: 00113B To keep or not to keep the rule/s?! Slide 9 Association rules Deakin University CRICOS Provider Code: 00113B Evaluation metrics ̶ Support ̶ Is the relative frequency of occurrence of an item set in the container set.   – (i.e. Fraction of total items that contain a specific occurrence) ̶ Filters out rules that are not worth considering further. ̶ Support({News})=5/6=0.83 ̶ Support({News, Finance})=4/6=0.67 ̶ Support({Sports})=…? ̶ {News} ‐> {Sports}: Support({News, Sports})=2/6=0.33 ̶ {News, Finance} ‐> {Arts}: Support({News, Finance, Arts})=0/6=0 Slide 10 Sample data set Source: Page 198, R1.Ch6 Association rules Deakin University CRICOS Provider Code: 00113B What is the shortcoming of support? Slide 11 Association rules Deakin University CRICOS Provider Code: 00113B Evaluation metrics ̶ Confidence ̶ Measures the likelihood of occurrence of the right‐side of the rule (i.e., consequent) out of all the items in the  container that contain the left‐side of the rule (i.e., antecedent). This is the reliability of the rule. ?????????? ? → ? ??????? ? ⋃ ? ??????? ? ?????????? ???? → ??????? , / / 0.8 ?????????? ????, ??????? → ?????? ??????? ????, ???????, ?????? ??????? ????, ??????? 2/6 4/6 0.5 Slide 12 Sample data set Source: Page 198, R1.Ch6 Association rule generic form: {Antecedent(s)} → {Consequent(s)} Association rules Deakin University CRICOS Provider Code: 00113B What is the shortcoming of confidence? Slide 13 Association rules Deakin University CRICOS Provider Code: 00113B Evaluation metrics ̶ Lift ̶ Is similar to confidence; however, it considers the support of the right‐side of the rule too. Values closer to 1  indicate non‐useful rules, larger lift values indicate more significant rules. ???? ? → ? ??????? ? ⋃ ? ??????? ? ??????? ? ???? ????, ??????? → ?????? ??????? ????, ???????, ?????? ??????? ????, ??????? ??????? ?????? 2/6 4/6 2/6 1.5 Slide 14 Sample data set Source: Page 198, R1.Ch6 Quiz! Deakin University CRICOS Provider Code: 00113B In a set of 10,000 transactions…  ̶ an analysis shows that 6,000 of customer transactions include computer games, while 7,500  include videos, and 4,000 include both computer games and videos. What is the confidence of  the rule {computer games} ‐> {videos}? ̶ A: 0.40 ̶ B: 0.89 ̶ C: 0.76 ̶ D: 0.67 Slide 15 Rule generation process Deakin University CRICOS Provider Code: 00113B Two main steps ̶ Step 1: Finding all frequent item sets ̶ Look at all possible combinations of items ̶ There will be 2 1 item sets in a set of ? items ̶ Filtering non‐important items out (using support) ̶ Step 2: Generating/extracting rules from frequent item sets ̶ Look at all possible rules ̶ For a frequent item set with ? items, there will be 2 2 rules ̶ Filter out rules that are not significant (using confidence or lift) Slide 16 Rule generation process Deakin University CRICOS Provider Code: 00113B Example… ̶ Media website ̶ Items: News, Finance, Sports, Entertainment ̶ Item filtered out: Arts Slide 17 Source: Page 201, R1.Ch6 all possible item sets in a lattice form, to  be used to find frequent item sets which item set is frequent? Rule generation process Deakin University CRICOS Provider Code: 00113B Apriori algorithm ̶ To find frequent item sets more efficiently ̶ Makes use of support of item sets ̶ Item sets with a support of larger than a threshold are frequent ̶ Rule 1… – If an item set is frequent, then all its subsets are frequent Slide 18 Source: Page 202, R1.Ch6 Rule generation process Deakin University CRICOS Provider Code: 00113B Slide 19 Source: Page 203, R1.Ch6 Apriori algorithm ̶ An algorithm to find frequent item sets ̶ Makes use of support of item sets ̶ Item sets with a support of larger than a threshold are frequent ̶ Rule 2… – If an item set is infrequent, then all its supersets are infrequent Animation of the algorithm in action Deakin University CRICOS Provider Code: 00113B Various sources exist, e.g. https://www.youtube.com/watch?v=TcUlzuQ27iQ Slide 20 Rule generation process Deakin University CRICOS Provider Code: 00113B Slide 21 Generating/extracting rules ̶ Generate all 2 2 rules for each frequent item set with ? items ̶ Makes use of confidence or lift of rules to filter out non‐significant rules ̶ In the previous example… ̶ For the item set {News, Sports, Finance}, there will be the following rules/confidence values: ̶ {News, Sports} ‐> {Finance}: confidence=1.0 ̶ {News, Finance} ‐> {Sports}: confidence=0.5 ̶ {Sports, Finance} ‐> {News}: confidence=1.0 ̶ {News} ‐> {Sports, Finance}: confidence=0.4 ̶ {Sports} ‐> {News, Finance}: confidence=1.0 ̶ {Finance} ‐> {News, Sports}: confidence=0.5 all rules with a confidence  a threshold  will be kept as output Rule generation process Deakin University CRICOS Provider Code: 00113B Slide 22 Frequent pattern (FP)‐growth algorithm ̶ Another algorithm for finding frequent item sets ̶ Extra reading… ̶ Details are not examinable ̶ Reference: Pages 206‐210, R1.Ch6 ̶ FP‐growth algorithm… ̶ works on the basis of compressing item sets into compressed tree structures called FP‐Trees ̶ is supposed to be more efficient than the apriori algorithm Sample exam question Deakin University CRICOS Provider Code: 00113B You are given a data set including 1,000 shopping transactions. In this data set, there are transactions that include items  as listed in the table below: ̶ a) Given the above transaction set, will you say the association rule  ???? → ???? represents a correct and likely association? Justify your answer. ̶ b) Given Confidence X → Y ⋃ , calculate the Confidence of the association rule  ????? → ????? in the above transaction set, and ̶ c) Briefly explain the main shortcoming/s of Confidence as related to this case. What other association rule analysis evaluation metric do you suggest to  be used to address the shortcoming/s of Confidence? Justify your answer. 6 + 8 + 6 = 20 Marks Slide 23 Items Frequency of occurrence in transactions Milk and DVD 650 Milk and Beer 20 Bread and Beer 35 Towel and Milk and DVD 15 Clock and Towel 575 Clock 620 Deakin University CRICOS Provider Code: 00113B Questions …? Ask now! and/or Post on CloudDeakin, and/or Email me at: [email protected] Slide 24 Microsoft PowerPoint - Lecture 10-s.pptx Time series forecasting Deakin University CRICOS Provider Code: 00113B Lecture 10 Learning objectives In this lecture… ̶ Understanding time series ̶ Understanding time series analysis categories ̶ Data driven methods ̶ Model driven methods ̶ Understanding the logic of time series forecasting model validation ̶ A sample exam question Deakin University CRICOS Provider Code: 00113B Slide 2 Time series Deakin University CRICOS Provider Code: 00113B So far… ̶ Predictive models on cross‐sectional data ̶ A set of predictors or independent variables ̶ To predict the class or dependent variable (different from the predictors) ̶ Regardless of the time dimension ̶ Examples… – Use bus route and trip data to predict the type of bus delay – Use customer demographic data or shopping behavior to predict customer churn – Use house characteristics to predict its sale price Slide 3 Time series Deakin University CRICOS Provider Code: 00113B What if... ̶ There is a time dimension (data are time‐stamped) ̶ Aim: To predict the value/s of an attribute that is/are changing over time Slide 4 Image source: https://desertscreenwritersgroup.com/2015/09/21/screenplay‐sequence/ Image source: https://aboveintelligent.com/the‐a‐i‐gold‐mine‐predicting‐ stock‐market‐success‐19082ec87ef5 Time series Deakin University CRICOS Provider Code: 00113B Mini case study ̶ Demand forecasting ̶ An emergency hospital wants to estimate their staff requirements (doctors,  specialists, nurses, support staff) ̶ Considerations… – Weather seasons: spike in demand because of climatic conditions, different activities  people engage in – Recent years: overall demand has grown as a result of growth in region – These all mean: there is seasonality and trend in the demand for the emergency services ̶ Aim: The hospital would like to… – forecast the demand for different staff requirements (weekly, monthly, annually) – plan for required resources (rostering, on call) Slide 5 Image source: Page 307, R1.Ch10 every few months, the  demand increases and  then decreases  (seasonality) the general trend shows growth in  demand over time Time series Deakin University CRICOS Provider Code: 00113B Terminology ̶ Time periods ̶ Refers to any time interval that is of interest ̶ E.g., seconds, minutes, weeks, months, years, etc. ̶ Horizon ̶ The time period for which forecasting is done ̶ E.g., next week, three weeks from now, or two years from now ̶ Forecast error ̶ Is the difference between the predicted value of the attribute and its actual value at any time ̶ Calculated as: ? ? ? Slide 6 forecast at  time t the actual value at  time t Time series Deakin University CRICOS Provider Code: 00113B Data components ̶ Time series data are called non‐stationary if the data exhibits… ̶ Seasonality: The data have regular and predictable changes that recur over time, with a (relatively) fixed period. This  is called cyclicality when the data have regular changes that recur over time, but with a non‐fixed period. ̶ Trend: The data have a pattern of gradual change over time. Slide 7 ̶ Random noise: The data have some normal fluctuations even after the  seasonality and trend components have been taken out. ̶ The above characteristics will result in different means and variances over time. Image source: Page 307, R1.Ch10 Deakin University CRICOS Provider Code: 00113B Slide 8 Can we use the values of one attribute to predict its own values over time? Time series analysis type 1 Deakin University CRICOS Provider Code: 00113B Data‐driven category ̶ In data‐driven time series analysis… ̶ There are no predictors ̶ The predictor and target attribute are the same ̶ Aim: To predict the values of one attribute from the values of the same attribute over time Slide 9 Data driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Naïve forecasting ̶ Simply assumes that the forecast value ? ? ̶ Will not look at any other previous values of the attribute ̶ Ignores trend and seasonality (why?) Slide 10 Image source: Page 307, R1.Ch10 the forecast value  of Y for the month  immediately after  Oct‐11 will be  equal to the value  of Y in Oct‐11 Data driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Simple average forecasting ̶ Assumes that the forecast value ? ??? ? , ? , … , ? ̶ Will look at all of the previous values of the attribute ̶ Ignores trend and seasonality (why?) Slide 11 Image source: https://grisha.org/blog/2016/01/29/triple‐exponential‐smoothing‐forecasting/ Altered the forecast value  of attribute on the  y‐axis will be the  average of all  values of the  attribute from t=6  to t=0 Data driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Moving average forecasting ̶ Assumes that the forecast value ? ??? ? , ? , … , ? ̶ Will look at a limited number of recent values of the attribute (? recent values) ̶ Considers trend and seasonality (why?) Slide 12 the forecast value  of attribute on the  y‐axis will be the  average of the last  4 values of the  attribute from t=6  to t=3 Image source: https://grisha.org/blog/2016/01/29/triple‐exponential‐smoothing‐forecasting/ Altered Data driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Weighted moving average forecasting ̶ Assumes that the forecast value ? ⋯ ⋯ ̶ Will look at a limited number of recent values of the attribute (? recent values) ̶ Assumes the more recent values should influence the forecast more ̶ Considers trend and seasonality ̶ E.g.,  – look at four values: 90, 89, 88, 89 (starting from the most recent) to forecast the next value – if weights are (starting from the most recent): 0.4, 0.3, 0.2, 0.1 – next value will be:  . . . . . . . . 89.2 Slide 13 Data driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ A quick comparison so far… Slide 14 Image source: https://grisha.org/blog/2016/01/29/triple‐exponential‐smoothing‐forecasting/ Image source: Page 310, R1.Ch10 Data driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Exponential smoothing ̶ Assumes that the forecast value ? ? ? 1 ? ? ̶ Will look at both actual and forecasted values at previous time periods ̶ Considers trend and seasonality ̶ Note… – ? 1: Naïve forecasting – Smaller ? values will result in smoother forecasts (close to the trend) – Typically: ? is between 0.2 and 0.4 Slide 15 Image source: Page 311, R1.Ch10 Deakin University CRICOS Provider Code: 00113B Slide 16 Can we use time as a predictor to forecast the values of an attribute? Time series analysis type 2 Deakin University CRICOS Provider Code: 00113B Model‐driven category ̶ In model‐driven time series analysis… ̶ The time dimension is the main predictor ̶ There may be other predictors (multivariate time series forecasting) ̶ Aim: to predict the values of one attribute from the values of the time dimension (and other attributes over time) Slide 17 Model driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Simple linear regression ̶ Time period as the independent variable (i.e., ?) ̶ The time series value (the attribute to be forecasted) as the dependent variable (i.e., ?) ̶ Will pick the general trend of the data ̶ Will not fit the data well ̶ Will ignore seasonality Slide 18 Image source: Page 315, R1.Ch10 Model driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Linear regression with seasonality (multiple regression) ̶ Adding dummy variables for time periods (0 or 1) as independent variables ̶ The time series value (the attribute to be forecasted) as the dependent variable ̶ Will fit the data very well ̶ Will pick the seasonality and trend of the data Slide 19 Image source: Page 317, R1.Ch10 Image source: Page 316, R1.Ch10 Model driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Autoregressive forecasting ̶ Makes use of the autocorrelation concept; the values of one attribute are correlated with the values of the same  attribute in the past ̶ The variable is regressed on its own lagged (prior) values; because of the correlation ̶ The lag can be any number of time periods (depending on the data) – Can be determined from experience/intuition – Can be determined through application of several lag sizes Slide 20 Image source: Page 318, R1.Ch10 Autocorrelation the values are  autocorrelated (values in the  different columns  are strongly  correlated) lag=6 months Model driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Autoregressive forecasting ̶ Implementation using windowing ̶ Predict the next value/s from previous values as predictors Slide 21 Image source: Page 318, R1.Ch10 Recreated the lagged values will be  used to predict the next  value (window size=6,  step=1) the first value after each  window becomes the  label (horizon=1) Model driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Autoregressive forecasting ̶ Example… – Historical monthly profit of a product – From January 2009 to June 2010 – Aim: To develop a profitability forecasting model – Step 1 – set up windowing (shown in the figure) – Step 2 – train a predictive model – Step 3 – generate forecasts Slide 22 Image source: Page 321, R1.Ch10 Windowing transformation Model driven time series forecasting Deakin University CRICOS Provider Code: 00113B Methods ̶ Autoregressive forecasting ̶ Example…(cont.) – Historical monthly profit of a product – From January 2009 to June 2010 – Aim: To develop a profitability forecasting model – Step 1 – set up windowing – Step 2 – train a predictive model (multiple linear regression in this case) – Step 3 – generate forecasts (shown in the figure) Slide 23 Image source: Page 326, R1.Ch10 Generating forecasts (in red) Data driven vs. Model driven Deakin University CRICOS Provider Code: 00113B Choosing a method ̶ Data‐driven ̶ One‐step ahead only ̶ Suitable to data with local patterns ̶ Model‐driven ̶ Overcomes the one‐step ahead limitation ̶ Suitable to data with global patterns Slide 24 Image source: Page 314, R1.Ch10 Forecasting model validation Deakin University CRICOS Provider Code: 00113B Forward chaining ̶ AKA., Rolling‐origin ̶ Assign each data point in time as a test data point ̶ Assign all previous data points as training data Slide 25 Source of  images:  https://robjhynd man.com/hyndsi ght/tscv/ one‐step ahead forecasting  model evaluation four‐step ahead forecasting  model evaluation Forecasting model validation Deakin University CRICOS Provider Code: 00113B Resampling ̶ Only for autoregressive models ̶ Similar logic to any other predictive modeling task ̶ Includes… – K‐fold cross validation – LOOCV – Bootstrapping ̶ Details discussed in Lecture 4 Slide 26 Sample exam question Deakin University CRICOS Provider Code: 00113B You were given a data set of the number of houses  sold in a particular city over a period of 4 years. You  have visualized the number of houses sold with time  as index dimension and have obtained result in the  figure: ̶ a) Would you say that the data set is non‐stationary? Justify  your answer.  ̶ b) Which of the following approaches would be best suited  to predict house sales, given this data set: simple linear  regression or autoregressive forecasting? Justify your  answer. ̶ c) If you were to utilize autoregressive forecasting, what  windowing frame would be appropriate? Justify your  answer. 6 + 10 + 4 = 20 Marks Slide 27 Deakin University CRICOS Provider Code: 00113B Questions …? Ask now! and/or Post on CloudDeakin, and/or Email me at: [email protected] Slide 28 Notes- Sample question 2 Lecture 7 notes Sample Question 3 Lecture 10 notes Question 2
Oct 21, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here