Created
May 17, 2021 00:02
-
-
Save axjack/a7cedddb103f673daef0c02f6fea3804 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(arules) | |
library(tidyverse) | |
data("Groceries") | |
Groceries %>% summary() | |
# ルール抽出 | |
aparm <- list(support=0.001,confidence=0.5,minlen=2,maxlen=2) | |
rules <- apriori(Groceries, parameter = aparm ) | |
# データフレーム化 | |
DATAFRAME(rules,setStart = '', itemSep = ',', setEnd = '') -> df.rules | |
# 整形してView | |
df.rules %>% | |
mutate(support_inPcnt = round(100 * support,2), | |
confidence_inPcnt = round(100 * confidence,2), | |
converge_inPcnt = round(100 * coverage,2), | |
right_converge = confidence/lift, | |
right_converge_inPcnt = round(100 * right_converge,2), | |
) %>% | |
rename( | |
`左辺` = LHS, | |
`右辺` = RHS, | |
`支持度[%]` = support_inPcnt, | |
`確信度[%]` = confidence_inPcnt, | |
`左辺支持度[%]` = converge_inPcnt, | |
`右辺支持度[%]` = right_converge_inPcnt, | |
`件数` = count, | |
`リフト` = lift | |
) %>% | |
select(左辺, 右辺, 件数, `左辺支持度[%]`, `右辺支持度[%]`, `支持度[%]`,`確信度[%]`,`リフト` | |
) %>% | |
View() | |
# see | |
# https://github.com/mhahsler/arules/blob/master/NEWS.md#arules-16-6-05142020 | |
# https://medium-s.jp/r-association-analysis/ | |
# http://www.is.ouj.ac.jp/lec/20data/slide/index.html | |
# http://www.is.ouj.ac.jp/lec/20data/slide/data2012.pdf | |
# https://documentation.sas.com/doc/ja/emref/14.3/n16x97j506upgin1l90wrfc1rg0l.htm#p1l4q4h83851nhn1f4nfvmiondon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(arules) | |
library(tidyverse) | |
data("Groceries") | |
Groceries %>% summary() | |
# ルール抽出 | |
aparm <- list(support=0.001,confidence=0.5,minlen=2,maxlen=2) | |
rules <- apriori(Groceries, parameter = aparm ) | |
# データフレーム化 | |
DATAFRAME(rules,setStart = '', itemSep = ',', setEnd = '') -> df.rules | |
# 整形してView | |
df.rules %>% | |
mutate(support_inPcnt = round(100 * support,2), | |
confidence_inPcnt = round(100 * confidence,2), | |
converge_inPcnt = round(100 * coverage,2), | |
right_converge = confidence/lift, | |
right_converge_inPcnt = round(100 * right_converge,2), | |
) %>% | |
rename( | |
`左辺` = LHS, | |
`右辺` = RHS, | |
`支持度[%]` = support_inPcnt, | |
`確信度[%]` = confidence_inPcnt, | |
`左辺支持度[%]` = converge_inPcnt, | |
`右辺支持度[%]` = right_converge_inPcnt, | |
`件数` = count, | |
`リフト` = lift | |
) %>% | |
select(左辺, 右辺, 件数, `左辺支持度[%]`, `右辺支持度[%]`, `支持度[%]`,`確信度[%]`,`リフト` | |
) %>% | |
View() | |
# see | |
# https://github.com/mhahsler/arules/blob/master/NEWS.md#arules-16-6-05142020 | |
# https://medium-s.jp/r-association-analysis/ | |
# http://www.is.ouj.ac.jp/lec/20data/slide/index.html | |
# http://www.is.ouj.ac.jp/lec/20data/slide/data2012.pdf | |
# https://documentation.sas.com/doc/ja/emref/14.3/n16x97j506upgin1l90wrfc1rg0l.htm#p1l4q4h83851nhn1f4nfvmiondon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment