The cl-association-rules Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-association-rules Reference Manual

This is the cl-association-rules Reference Manual, version 0.0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 03:28:17 2022 GMT+0.

Table of Contents


1 Introduction

cl-association-rules

This project aims to implement the most well known strategies and utilities when mining association rules from a dataset of transactions. For now, only the apriori algorithm is implemented. It works at least on sbcl, ecl, ccl, abcl and clisp.

How do i use it?

This section assumes you use quicklisp. If you don't, you should! Download and learn about it here.

Once you have quicklisp loaded, simply do:

(ql:quickload :cl-association-rules)

And it's all up and running. To run the tests do:

(ql:quickload :cl-association-rules-tests)

Please report if any tests fail in your Common Lisp implementation.

To make it easier to write, the cl-association-rules package also has the nickname "rules".

Example

> (ql:quickload :cl-association-rules)
(:CL-ASSOCIATION-RULES)  

> (rules:apriori '((1 2 3 4) ;; each of these lines is a transaction
                   (1 2 4)
                   (1 2)
                   (2 3 4)
                   (2 3)
                   (3 4)
                   (2 4)))
((3) => (2). Support is 3/7 and confidence is 3/4.
 (4 1) => (2). Support is 2/7 and confidence is 1.
 (4) => (2). Support is 4/7 and confidence is 4/5.
 (1) => (2). Support is 3/7 and confidence is 1.
 (3) => (4). Support is 3/7 and confidence is 3/4.)

API

(apriori dataset &key (support 0.17) (confidence 0.68) (test #'equalp))

Apriori calculates the association rules in "dataset" using the apriori algorithm. Expects a dataset of the form ((1 2 3 4) (3 2 7 9) (9) (2 3 8) (2 0)), where each line is a transaction. You can also costumize the support (defaults to 0.17), the confidence (defaults to 0.68) and the equality operator (defaults to the lisp "equalp" function). The output is a list of mined rules, where each rule is an instance of a struct with fields posttuple, pretuple, support and confidence. This method may signal type-error.

> (defvar *mined-rules* (rules:apriori '((1 2 3 4)
                                         (1 2 3 7)
                                         (1 9)
                                         (2 10 15 4)
                                         (1 3 4 11)
                                         (15 3 1 20))))
*MINED-RULES* ;; ((2 1) => (3). Support is 1/3 and confidence is 1.
              ;;  (3 2) => (1). Support is 1/3 and confidence is 1.
              ;;  (1) => (3). Support is 2/3 and confidence is 4/5.
              ;;  (3) => (1). Support is 2/3 and confidence is 1.)

> (rules:rule-pretuple (first *MINED-RULES*))
(2 1) ;; accessing member "pretuple" of the rule struct. Other members are
      ;; "posttuple", "support" and "confidence".

Contributing

If you have any suggestions, bug reports, etc, please fill in an issue describing it. If you have the time and want to contribute, that is even better! Submit some tests too :)

Here is what I'm thinking might make sense to implement next:

License

MIT


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-association-rules

An implementation of the apriori algorithm to mine association rules in Common Lisp.

Author

Diogo Franco

License

MIT

Version

0.0.1

Source

cl-association-rules.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


3.1.1 cl-association-rules/cl-association-rules.asd

Source

cl-association-rules.asd.

Parent Component

cl-association-rules (system).

ASDF Systems

cl-association-rules.


3.1.2 cl-association-rules/package.lisp

Source

cl-association-rules.asd.

Parent Component

cl-association-rules (system).

Packages

cl-association-rules.


3.1.3 cl-association-rules/rule.lisp

Dependency

package.lisp (file).

Source

cl-association-rules.asd.

Parent Component

cl-association-rules (system).

Public Interface
Internals

3.1.4 cl-association-rules/apriori.lisp

Dependency

rule.lisp (file).

Source

cl-association-rules.asd.

Parent Component

cl-association-rules (system).

Public Interface

apriori (function).

Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 cl-association-rules

Source

package.lisp.

Nickname

rules

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Ordinary functions

Function: apriori (dataset &key support confidence test)

Calculates the association rules in the dataset using the apriori algorithm. Expects a dataset of the form
((1 2 3 4)
(3 2 7 9)
(9)
(2 3 8)
(2 0)),
where each line is a transaction.
Returns a list of the mined rules.

Package

cl-association-rules.

Source

apriori.lisp.

Function: make-rule (&key pretuple posttuple support confidence)
Package

cl-association-rules.

Source

rule.lisp.

Reader: rule-confidence (instance)
Writer: (setf rule-confidence) (instance)
Package

cl-association-rules.

Source

rule.lisp.

Target Slot

confidence.

Reader: rule-posttuple (instance)
Writer: (setf rule-posttuple) (instance)
Package

cl-association-rules.

Source

rule.lisp.

Target Slot

posttuple.

Reader: rule-pretuple (instance)
Writer: (setf rule-pretuple) (instance)
Package

cl-association-rules.

Source

rule.lisp.

Target Slot

pretuple.

Reader: rule-support (instance)
Writer: (setf rule-support) (instance)
Package

cl-association-rules.

Source

rule.lisp.

Target Slot

support.


5.1.2 Standalone methods

Method: print-object ((object rule) stream)
Source

rule.lisp.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Function: copy-rule (instance)
Package

cl-association-rules.

Source

rule.lisp.

Function: generate-candidates (frequent-items non-frequent-items all-items test)

Generates the next candidate set, from the previous frequent and non-frequent itemsets.

Package

cl-association-rules.

Source

apriori.lisp.

Function: generate-rules (frequent-itemsets min-confidence num-transactions test)

From the frequent itemsets found by apriori, generate association rules for a given min-confidence.

Package

cl-association-rules.

Source

apriori.lisp.

Function: get-all-items (dataset test)

From a dataset, return the unique items as a list.

Package

cl-association-rules.

Source

apriori.lisp.

Function: get-frequent-items (candidate-set min-support dataset test frequent-items-hash)

From a candidate set and support threshold, return the items that are frequent and non-frequent in the dataset.

Package

cl-association-rules.

Source

apriori.lisp.

Function: rule-p (object)
Package

cl-association-rules.

Source

rule.lisp.

Function: set-equal-p (set-1 set-2 test)

Returns t if two sets of elements are equal

Package

cl-association-rules.

Source

apriori.lisp.


5.2.2 Structures

Structure: rule
Package

cl-association-rules.

Source

rule.lisp.

Direct superclasses

structure-object.

Direct methods

print-object.

Direct slots
Slot: pretuple
Readers

rule-pretuple.

Writers

(setf rule-pretuple).

Slot: posttuple
Readers

rule-posttuple.

Writers

(setf rule-posttuple).

Slot: support
Readers

rule-support.

Writers

(setf rule-support).

Slot: confidence
Readers

rule-confidence.

Writers

(setf rule-confidence).


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
A   C   F   G   M   P   R   S  
Index Entry  Section

(
(setf rule-confidence): Public ordinary functions
(setf rule-posttuple): Public ordinary functions
(setf rule-pretuple): Public ordinary functions
(setf rule-support): Public ordinary functions

A
apriori: Public ordinary functions

C
copy-rule: Private ordinary functions

F
Function, (setf rule-confidence): Public ordinary functions
Function, (setf rule-posttuple): Public ordinary functions
Function, (setf rule-pretuple): Public ordinary functions
Function, (setf rule-support): Public ordinary functions
Function, apriori: Public ordinary functions
Function, copy-rule: Private ordinary functions
Function, generate-candidates: Private ordinary functions
Function, generate-rules: Private ordinary functions
Function, get-all-items: Private ordinary functions
Function, get-frequent-items: Private ordinary functions
Function, make-rule: Public ordinary functions
Function, rule-confidence: Public ordinary functions
Function, rule-p: Private ordinary functions
Function, rule-posttuple: Public ordinary functions
Function, rule-pretuple: Public ordinary functions
Function, rule-support: Public ordinary functions
Function, set-equal-p: Private ordinary functions

G
generate-candidates: Private ordinary functions
generate-rules: Private ordinary functions
get-all-items: Private ordinary functions
get-frequent-items: Private ordinary functions

M
make-rule: Public ordinary functions
Method, print-object: Public standalone methods

P
print-object: Public standalone methods

R
rule-confidence: Public ordinary functions
rule-p: Private ordinary functions
rule-posttuple: Public ordinary functions
rule-pretuple: Public ordinary functions
rule-support: Public ordinary functions

S
set-equal-p: Private ordinary functions

Jump to:   (  
A   C   F   G   M   P   R   S