-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path8-arules.Rmd
74 lines (50 loc) · 1.1 KB
/
8-arules.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
title: "R Notebook"
output: html_notebook
---
```{r}
install.packages(c("arules", "arulesViz"))
library(arules)
library(arulesViz)
library(tidyverse)
library(haven)
library(data.table)
```
## the BKL study
Technical, Mathematical, Artistic, Computer, Cognitive, Managerial, Interpersonal, Self-organization, Physical, Availability, Office
Link to description of the study (in English) -- https://arxiv.org/abs/1908.06731
```{r}
bkl <- readRDS("../data/data-bkl.rds")
bkl
```
1. Convert data.frame to matrix / sparse Matrix (e.g. Matrix package)
2. Then use `as()` function
```{r}
dane_arules_m <- as.matrix(bkl)
skills <- as(dane_arules_m, "transactions")
skills
```
```{r}
summary(skills)
```
3. apriori algorithm
```{r}
result <- apriori(skills)
```
4. inspect
```{r}
df <- inspect(result)
df %>% rename(zal=2) %>% arrange(-lift)
```
5. Visualise results
```{r}
arulesViz::ruleExplorer(result)
```
```{r}
arulesViz::inspectDT(result)
```
How to specify your own defaults
```{r}
rules_custom <- apriori(data = skills, parameter = list(support = 0.2, confidence = 0.7))
inspect(rules_custom)
```