process_mining
This crate contains basic data structures, functions and utilities for Process Mining.
Visit docs.rs/process_mining/ to view the full documentation of this crate.
Modules
Currently, the following modules are implemented:
event_log
(Event Logs, traditional and object-centric)
petri_net
(Petri nets)
alphappp
(Alpha+++ discovery algorithm)
Getting Started
To get started, you can try importing an XES event log using the following code snippet:
use process_mining::{import_xes_file, XESImportOptions};
let log_res = import_xes_file("log.xes", XESImportOptions::default());
match log_res {
Ok(log) => {
println!("Imported event log with {} traces", log.traces.len())
},
Err(e) => {
eprintln!("XES Import failed: {:?}", e)
},
}
Examples
use std::{
fs::File,
io::BufReader,
time::Instant,
};
use process_mining::{
event_log::{
activity_projection::EventLogActivityProjection,
constants::ACTIVITY_NAME,
import_xes::{build_ignore_attributes, XESImportOptions},
stream_xes::{
construct_log_data_cell, stream_xes_from_path,
},
},
import_ocel_xml_file, import_xes_file, OCEL,
};
fn main() {
let xes_path = "../../../dow/event_data/BPI Challenge 2018.xes.gz";
let now = Instant::now();
let log = import_xes_file(xes_path, XESImportOptions::default()).unwrap();
println!(
"Parsed XES with {} cases in {:#?}",
log.traces.len(),
now.elapsed()
);
let log_data = construct_log_data_cell();
let now = Instant::now();
let st_res = stream_xes_from_path(
xes_path,
XESImportOptions {
ignore_event_attributes_except: Some(build_ignore_attributes(vec![ACTIVITY_NAME])),
ignore_trace_attributes_except: Some(build_ignore_attributes(Vec::<&str>::new())),
ignore_log_attributes_except: Some(build_ignore_attributes(Vec::<&str>::new())),
..XESImportOptions::default()
},
&log_data,
);
match st_res {
Ok(st) => {
let projection: EventLogActivityProjection = st.into();
println!(
"Streamed XES into Activity Projection with {} variants in {:#?}",
projection.traces.len(),
now.elapsed()
);
}
Err(e) => {
eprintln!("Error while streaming parsing: {}", e);
}
}
let ocel = import_ocel_xml_file("../../../dow/event_data/order-management.xml");
println!(
"Imported OCEL2 XML with {} objects and {} events in {:#?}",
ocel.objects.len(),
ocel.events.len(),
now.elapsed()
);
let ocel: OCEL = serde_json::from_reader(BufReader::new(
File::open("../../../dow/event_data/order-management.json").unwrap(),
))
.unwrap();
println!(
"Imported OCEL2 JSON with {} objects and {} events in {:#?}",
ocel.objects.len(),
ocel.events.len(),
now.elapsed()
);
}
Example output:
Parsed XES with 43809 cases in 14.67024004s
Streamed XES into Activity Projection with 28457 variants in 6.136536956s
Imported OCEL2 XML with 10840 objects and 21008 events in 6.227374964s
Imported OCEL2 JSON with 10840 objects and 21008 events in 6.330307052s