-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathfrequent_pattern.clj
More file actions
50 lines (44 loc) · 1.33 KB
/
Copy pathfrequent_pattern.clj
File metadata and controls
50 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(ns examples.classification
(:require
[zero-one.geni.core :as g]
[zero-one.geni.ml :as ml]))
(def dataset
(-> (g/table->dataset
[['("1" "2" "5")]
['("1" "2" "3" "5")]
['("1" "2")]]
[:items])))
(def model
(ml/fit
dataset
(ml/fp-growth {:items-col :items
:min-confidence 0.6
:min-support 0.5})))
(g/show (ml/frequent-item-sets model))
;;=>
;; +---------+----+
;; |items |freq|
;; +---------+----+
;; |[1] |3 |
;; |[2] |3 |
;; |[2, 1] |3 |
;; |[5] |2 |
;; |[5, 2] |2 |
;; |[5, 2, 1]|2 |
;; |[5, 1] |2 |
;; +---------+----+
(g/show (ml/association-rules model))
;;=>
;; +----------+----------+------------------+----+
;; |antecedent|consequent|confidence |lift|
;; +----------+----------+------------------+----+
;; |[2, 1] |[5] |0.6666666666666666|1.0 |
;; |[5, 1] |[2] |1.0 |1.0 |
;; |[2] |[1] |1.0 |1.0 |
;; |[2] |[5] |0.6666666666666666|1.0 |
;; |[5] |[2] |1.0 |1.0 |
;; |[5] |[1] |1.0 |1.0 |
;; |[1] |[2] |1.0 |1.0 |
;; |[1] |[5] |0.6666666666666666|1.0 |
;; |[5, 2] |[1] |1.0 |1.0 |
;; +----------+----------+------------------+----+