The cl-association-rules Reference Manual

Table of Contents

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 2.4 "Will Decker" on Wed Jun 20 10:58:10 2018 GMT+0.


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

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


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

2 Systems

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


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

2.1 cl-association-rules

Author

Diogo Franco

License

MIT

Description

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

Version

0.0.1

Source

cl-association-rules.asd (file)

Components

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

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


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-association-rules.asd

Location

cl-association-rules.asd

Systems

cl-association-rules (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-association-rules/package.lisp

Parent

cl-association-rules (system)

Location

package.lisp

Packages

cl-association-rules


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 cl-association-rules/rule.lisp

Dependency

package.lisp (file)

Parent

cl-association-rules (system)

Location

rule.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.4 cl-association-rules/apriori.lisp

Dependency

rule.lisp (file)

Parent

cl-association-rules (system)

Location

apriori.lisp

Exported Definitions

apriori (function)

Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 cl-association-rules

Source

package.lisp (file)

Nickname

rules

Use List

common-lisp

Exported Definitions
Internal Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 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 (file)

Function: make-rule &key (PRETUPLE PRETUPLE) (POSTTUPLE POSTTUPLE) (SUPPORT SUPPORT) (CONFIDENCE CONFIDENCE)
Package

cl-association-rules

Source

rule.lisp (file)

Function: rule-confidence INSTANCE
Function: (setf rule-confidence) VALUE INSTANCE
Package

cl-association-rules

Source

rule.lisp (file)

Function: rule-posttuple INSTANCE
Function: (setf rule-posttuple) VALUE INSTANCE
Package

cl-association-rules

Source

rule.lisp (file)

Function: rule-pretuple INSTANCE
Function: (setf rule-pretuple) VALUE INSTANCE
Package

cl-association-rules

Source

rule.lisp (file)

Function: rule-support INSTANCE
Function: (setf rule-support) VALUE INSTANCE
Package

cl-association-rules

Source

rule.lisp (file)


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

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: copy-rule INSTANCE
Package

cl-association-rules

Source

rule.lisp (file)

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 (file)

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 (file)

Function: get-all-items DATASET TEST

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

Package

cl-association-rules

Source

apriori.lisp (file)

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 (file)

Function: rule-p OBJECT
Package

cl-association-rules

Source

rule.lisp (file)

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 (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Structures

Structure: rule ()
Package

cl-association-rules

Source

rule.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods

print-object (method)

Direct slots
Slot: pretuple
Readers

rule-pretuple (function)

Writers

(setf rule-pretuple) (function)

Slot: posttuple
Readers

rule-posttuple (function)

Writers

(setf rule-posttuple) (function)

Slot: support
Readers

rule-support (function)

Writers

(setf rule-support) (function)

Slot: confidence
Readers

rule-confidence (function)

Writers

(setf rule-confidence) (function)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-association-rules.asd: The cl-association-rules<dot>asd file
cl-association-rules/apriori.lisp: The cl-association-rules/apriori<dot>lisp file
cl-association-rules/package.lisp: The cl-association-rules/package<dot>lisp file
cl-association-rules/rule.lisp: The cl-association-rules/rule<dot>lisp file

F
File, Lisp, cl-association-rules.asd: The cl-association-rules<dot>asd file
File, Lisp, cl-association-rules/apriori.lisp: The cl-association-rules/apriori<dot>lisp file
File, Lisp, cl-association-rules/package.lisp: The cl-association-rules/package<dot>lisp file
File, Lisp, cl-association-rules/rule.lisp: The cl-association-rules/rule<dot>lisp file

L
Lisp File, cl-association-rules.asd: The cl-association-rules<dot>asd file
Lisp File, cl-association-rules/apriori.lisp: The cl-association-rules/apriori<dot>lisp file
Lisp File, cl-association-rules/package.lisp: The cl-association-rules/package<dot>lisp file
Lisp File, cl-association-rules/rule.lisp: The cl-association-rules/rule<dot>lisp file

Jump to:   C   F   L  

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

A.2 Functions

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

(
(setf rule-confidence): Exported functions
(setf rule-posttuple): Exported functions
(setf rule-pretuple): Exported functions
(setf rule-support): Exported functions

A
apriori: Exported functions

C
copy-rule: Internal functions

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

G
generate-candidates: Internal functions
generate-rules: Internal functions
get-all-items: Internal functions
get-frequent-items: Internal functions

M
make-rule: Exported functions

R
rule-confidence: Exported functions
rule-p: Internal functions
rule-posttuple: Exported functions
rule-pretuple: Exported functions
rule-support: Exported functions

S
set-equal-p: Internal functions

Jump to:   (  
A   C   F   G   M   R   S  

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

A.3 Variables

Jump to:   C   P   S  
Index Entry  Section

C
confidence: Internal structures

P
posttuple: Internal structures
pretuple: Internal structures

S
Slot, confidence: Internal structures
Slot, posttuple: Internal structures
Slot, pretuple: Internal structures
Slot, support: Internal structures
support: Internal structures

Jump to:   C   P   S  

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

A.4 Data types

Jump to:   C   P   R   S  
Index Entry  Section

C
cl-association-rules: The cl-association-rules system
cl-association-rules: The cl-association-rules package

P
Package, cl-association-rules: The cl-association-rules package

R
rule: Internal structures

S
Structure, rule: Internal structures
System, cl-association-rules: The cl-association-rules system

Jump to:   C   P   R   S