prune_edges: Prune edges based on given percentage

Description Usage Arguments Details See Also

View source: R/prune_edges.R

Description

Prune edges based on given percentage

Usage

1
prune_edges(p, percentage = 0.2, max = -1)

Arguments

p

process map object created by create_pmap_graph() function

percentage

how many percentage of the edges should be pruned.

max

set max number of edges to keep. If max >= 0, the percentage parameter will be ignored. if max < 0 then max will be ignored and percentage will be used to prune.

Details

Create an event log

> library(dplyr)
> library(pmap)
> eventlog <- generate_eventlog(
  size_of_eventlog = 10000,
  number_of_cases = 2000,
  categories = c("campaign", "sale"),
  categories_size = c(10, 4))
> head(eventlog)
            timestamp   case_id          activity category
1 2017-01-01 02:14:50  Case 345  Activity 1 (campaign)   campaign
2 2017-01-01 02:26:24 Case 1625  Activity 2 (campaign)   campaign
3 2017-01-01 03:48:12 Case 1901     Activity 12 (sale)       sale
4 2017-01-01 03:57:54 Case 1029 Activity 10 (campaign)   campaign
5 2017-01-01 07:46:54  Case 215 Activity 10 (campaign)   campaign
6 2017-01-01 09:44:51 Case 1354  Activity 1 (campaign)   campaign
> str(eventlog)
'data.frame':	10000 obs. of  4 variables:
 $ timestamp  : POSIXct, format: "2017-01-01 02:14:50" "2017-01-01 02:26:24" ...
 $ case_id: chr  "Case 345" "Case 1625" "Case 1901" "Case 1029" ...
 $ activity : chr  "Activity 1 (campaign)" "Activity 2 (campaign)" "Activity 12 (sale)" "Activity 10 (campaign)" ...
 $ category : chr  "campaign" "campaign" "sale" "campaign" ...

Create a process map from the event log and render it directly.

> p <- create_pmap(eventlog, target_categories = c("sale"))
> render_pmap(p)

Figure: example.prune\_edges.none.svg

As you can see the activity map is very messy. Let's apply the prune_edges() to remove 50 percent edges.

> p %>% prune_edges(0.5) %>% render_pmap()

Figure: example.prune\_edges.edges.svg

It's cleaner, we can clean it further by remove 50 percent nodes with prune_nodes() function.

> p %>% prune_nodes(0.5) %>% prune_edges(0.5) %>% render_pmap()

Figure: example.prune\_edges.both.svg

One thing should be noticed, the order of pruning nodes and edges matters.

See Also

prune_nodes


twang2218/pmv documentation built on Nov. 6, 2021, 11:16 p.m.