fpgrowth: FP-Growth

Description Usage Arguments Examples

View source: R/fpgrowth.R

Description

FP-Growth algorithm - Jiawei Han, Jian Pei, and Yiwen Yin. Mining frequent patterns without candidate generation. SIGMOD Rec. 29, 2 (2000) <doi:10.1145/335191.335372>

Usage

1
2
fpgrowth(train, support = 0.01, confidence = 1, maxLength = 5,
  consequent = NULL, verbose = TRUE, parallel = TRUE)

Arguments

train

data.frame or transactions from arules with input data

support

minimum support

confidence

minimum confidence

maxLength

maximum length

consequent

filter consequent - column name with consequent/target class

verbose

verbose indicator

parallel

parallel indicator

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library("rCBA")
data("iris")

train <- sapply(iris,as.factor)
train <- data.frame(train, check.names=FALSE)
txns <- as(train,"transactions")

rules = rCBA::fpgrowth(txns, support=0.03, confidence=0.03, maxLength=2, consequent="Species",
           parallel=FALSE)

predictions <- rCBA::classification(train,rules)
table(predictions)
sum(as.character(train$Species)==as.character(predictions),na.rm=TRUE)/length(predictions)

prunedRules <- rCBA::pruning(train, rules, method="m2cba", parallel=FALSE)
predictions <- rCBA::classification(train, prunedRules)
table(predictions)
sum(as.character(train$Species)==as.character(predictions),na.rm=TRUE)/length(predictions)

Example output

Loading required package: rJava
Loading required package: arules
Loading required package: Matrix

Attaching package:arulesThe following objects are masked frompackage:base:

    abbreviate, write

Warning message:
Column(s) 1, 2, 3, 4, 5 not logical or factor. Applying default discretization (see '? discretizeDF'). 
2020-12-10 17:04:48 rCBA: initialized
2020-12-10 17:04:48 rCBA: data 150x126
	 took: 0.4  s
Dec 10, 2020 5:04:48 PM cz.jkuchar.rcba.fpg.FPGrowth run
INFO: FPG: start
Dec 10, 2020 5:04:48 PM cz.jkuchar.rcba.fpg.FPGrowth run
INFO: FPG: tree built (54)
2020-12-10 17:04:48 rCBA: rules 47
	 took: 0.46  s
2020-12-10 17:04:48 rCBA: initialized
2020-12-10 17:04:48 rCBA: data 150x5
	 took: 0.01  s
2020-12-10 17:04:48 rCBA: rules 47
	 took: 0.04  s
2020-12-10 17:04:49 rCBA: classification completed
	 took: 0.07  s
predictions
    setosa versicolor  virginica 
        53         48         49 
[1] 0.9466667
2020-12-10 17:04:49 rCBA: initialized
2020-12-10 17:04:49 rCBA: data 150x5
	 took: 0.01  s
2020-12-10 17:04:49 rCBA: rules 47
	 took: 0.03  s
2020-12-10 17:04:49 rCBA: pruning completed
	 took: 0.07  s
2020-12-10 17:04:49 rCBA: pruned rules 27
	 took: 0.02  s
2020-12-10 17:04:49 rCBA: initialized
2020-12-10 17:04:49 rCBA: data 150x5
	 took: 0  s
2020-12-10 17:04:49 rCBA: rules 27
	 took: 0.01  s
2020-12-10 17:04:49 rCBA: classification completed
	 took: 0.05  s
predictions
    setosa versicolor  virginica 
        51         48         51 
[1] 0.96

rCBA documentation built on May 30, 2019, 1:01 a.m.

Related to fpgrowth in rCBA...