LoginSignup
1
1

More than 5 years have passed since last update.

Rにおける頻出パターンマイニングと系列パターンマイニング

Last updated at Posted at 2018-09-08

Rで頻出パターンマイニングと系列パターンマイニングの手順をまとめてみました。

頻出パターンマイニング

library(arules) #頻出パターンマイニングのライブラリ
library(arulesViz) #可視化のためのライブラリ

#データの読み込み
ds <- read.transactions('C:\\path\\to\\dataForR.csv', sep=',', format='basket')

#データ確認
str(ds)
summary(ds)

#頻出パターンマイニング
ds.ap <- apriori(ds) #ルール抽出
inspect(head(sort(ds.ap, by="support"),n=10)) #上位10件のルールの表示
plot(ds.ap,method='graph',control=list(type='items',layout=layout.show())) #可視化

系列パターンマイニング

系列
library(arulesSequences) #系列パターンマイニングのライブラリ
library(arulesViz) #可視化のためのライブラリ

#データ読み込み
ds2 <- read_baskets('C:\\path\\to\\dataForR.csv', sep = ',', info = c("sequenceID","eventID","SIZE"))
#系列パターンマイニング
ds2.sp <- cspade(ds2, parameter=list(support=0.001), control=list(verbose=TRUE)) 

ちなみに、arulesSequencesのcspadeはRstudioで発生するbugがあるようです。

上記に関して、間違いなどあればご指摘ください。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1