wekaexplorer%twiki.di.uniroma1.it/pub/apprauto/webhome/weka2_2016.pdf · • weka contains an...

61
WEKA Explorer Second part

Upload: others

Post on 22-May-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

WEKA  Explorer    

Second  part  

Page 2: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

ML  algorithms  in  weka  belong  to  3  categories  

Page 3: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

Will see examples in each category (as we learn new algorithms)

1.  Classifiers (given a set of categories, learn to assign each instance to a category. These are TRAINED methods): Decision Trees, decision tables, conjunctive rules..

2.  Clustering (given a set of instances, group these instances in clusters according to some similarity function. These are UNTRAINED methods): Hierarchical clustering, DensityBased, etc)

3.  Association rules (given a set of instances, find frequent patterns, e.g. rules that show dependencies among the data. These are UNTRAINED methods): Apriori, Filtered Associator, ..

4.  Additional algorithms can be used, within the Experimenter (will see later)

Page 4: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 4  

Page 5: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 5  

Page 6: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 6  

Page 7: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 7  

Page 8: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 8  

Page 9: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 9  

Page 10: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 10  

Page 11: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 11  

Page 12: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 12  

Page 13: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 13  

Page 14: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 14  

Page 15: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 15  

Page 16: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 16  

Page 17: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 17  

Page 18: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 18  

Page 19: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 19  

Page 20: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 20  

Page 21: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 21  

Page 22: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 22  

Page 23: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 23  

Page 24: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 24  

Page 25: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 25  

Page 26: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 26  

Explorer: clustering data

•  WEKA contains “clusterers” for finding groups of similar instances in a dataset

•  Implemented schemes are: – k-Means, EM, Cobweb, X-means, FarthestFirst

•  Clusters can be visualized and compared to “true” clusters (if given)

•  Evaluation based on loglikelihood if clustering scheme produces a probability distribution

Page 27: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

febbraio 12, 2016 27  

•  Given k, the k-means algorithm is implemented in four steps:

– Partition objects into k nonempty subsets

– Compute seed points as the centroids of the clusters of the current partition (the centroid is the center, i.e., mean point, of the cluster)

– Assign each object to the cluster with the nearest seed point

– Go back to Step 2, stop when no more new assignment

The  K-­‐Means  Clustering  Method    

Page 28: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only
Page 29: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

right click: visualize cluster assignement

Page 30: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 30  

Explorer: finding associations

•  WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only with discrete data

•  Can identify statistical dependencies between groups of attributes: – milk, butter ⇒ bread, eggs (with confidence 0.9 and

support 2000)

•  Apriori can compute all rules that have a given minimum support and exceed a given confidence

Page 31: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

febbraio 12, 2016 31  

Basic Concepts: Frequent Patterns

•  itemset: A set of one or more items •  k-itemset X = {x1, …, xk} •  (absolute) support, or, support count of X:

Frequency or occurrence of an itemset X

•  (relative) support, s, is the fraction of transactions that contains X (i.e., the probability that a transaction contains X)

•  An itemset X is frequent if X’s support is no less than a minsup threshold

Customer buys diaper

Customer buys both

Customer buys beer

Tid Items bought

10 Beer, Nuts, Diaper

20 Beer, Coffee, Diaper

30 Beer, Diaper, Eggs

40 Nuts, Eggs, Milk

50 Nuts, Coffee, Diaper, Eggs, Milk

Page 32: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

febbraio 12, 2016 32  

Basic Concepts: Association Rules

•  Find all the rules X à Y with minimum support and confidence

–  support, s, probability that a transaction contains X ∪ Y

–  confidence, c, conditional probability that a transaction having X also contains Y

Let minsup = 50%, minconf = 50% Freq. Pat.: Beer:3, Nuts:3, Diaper:4, Eggs:3, {Beer,

Diaper}:3

Customer buys diaper

Customer buys both

Customer buys beer

Nuts, Eggs, Milk 40 Nuts, Coffee, Diaper, Eggs, Milk 50

Beer, Diaper, Eggs 30

Beer, Coffee, Diaper 20

Beer, Nuts, Diaper 10

Items bought Tid

n  Association rules: (many more!) n  Beer à Diaper (60%, 100%) n  Diaper à Beer (60%, 75%)

Page 33: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only
Page 34: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 34  

Page 35: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 35  

Page 36: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 36  

Page 37: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 37  

Page 38: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 38  

Page 39: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

AddiJonal  features  of  Explorer:  AMribute  SelecJon  and  VisualizaJon  

Page 40: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 40  

Explorer: attribute selection

•  Panel that can be used to investigate which (subsets of) attributes are the most predictive ones

•  Attribute selection methods contain two parts: – A search method: best-first, forward selection, random,

exhaustive, genetic algorithm, ranking – An evaluation method: correlation-based, wrapper,

information gain, chi-squared, …

•  Very flexible: WEKA allows (almost) arbitrary combinations of these two

•  Will see in more detail in dedicated labs

Page 41: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 41  

Page 42: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 42  

Page 43: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 43  

Page 44: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 44  

Page 45: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 45  

Page 46: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 46  

Page 47: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 47  

Page 48: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 48  

Page 49: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 49  

Explorer: data visualization •  Visualization very useful in practice: e.g. helps to determine

difficulty of the learning problem •  WEKA can visualize single attributes (1-d) and pairs of

attributes (2-d) •  Color-coded class values •  “Jitter” option to deal with nominal attributes (and to detect “hidden” data points). (Jittering occurs when you have too many instances placed on the same point, see http://blogs.sas.com/content/iml/2011/07/05/jittering-to-prevent-overplotting-in-statistical-graphics.html)

•  “Zoom-in” function

Page 50: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only
Page 51: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 51  

Page 52: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 52  

Page 53: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 53  

Page 54: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 54  

Page 55: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 55  

click on a cell

Page 56: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 56  

Page 57: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 57  

Page 58: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 58  

Page 59: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 59  

Page 60: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

12/02/16 University of Waikato 60  

Page 61: WEKAExplorer%twiki.di.uniroma1.it/pub/ApprAuto/WebHome/WEKA2_2016.pdf · • WEKA contains an implementation of the Apriori algorithm for learning association rules – Works only

References and Resources •  References:

–  WEKA website: http://www.cs.waikato.ac.nz/~ml/weka/index.html –  WEKA Tutorial:

•  Machine Learning with WEKA: A presentation demonstrating all graphical user interfaces (GUI) in Weka.

•  A presentation which explains how to use Weka for exploratory data mining. –  WEKA Data Mining Book:

•  Ian H. Witten and Eibe Frank, Data Mining: Practical Machine Learning Tools and Techniques (Second Edition)

–  WEKA Wiki: http://weka.sourceforge.net/wiki/index.php/Main_Page

–  Others: •  Jiawei Han and Micheline Kamber, Data Mining: Concepts and Techniques, 2nd

ed.