Skip to main content

dtrees_rs/
lib.rs

1//! Decision trees over binary features.
2//!
3//! * [DL8.5](algorithms::optimal::dl85::DL85) learns optimal trees by dynamic
4//!   programming with branch-and-bound and caching (Aglin, Nijssen and
5//!   Schaus, AAAI 2020). With search rules it becomes anytime: limited
6//!   discrepancy search (LDS-DL8.5, ECML PKDD 2022), Top-k, and the general
7//!   CA-DL8.5 framework (IDA 2026). See [`algorithms::optimal::rules`].
8//! * [LGDT](algorithms::greedy::LGDT) grows a tree greedily, choosing each
9//!   test with a depth-2 lookahead (IDA 2024).
10//!
11//! Data comes as a [`Cover`](cover::Cover), read from a text file by
12//! [`DataReader`](reader::data_reader::DataReader): one instance per line,
13//! the label first, then the 0/1 features.
14//!
15//! ```no_run
16//! use dtrees_rs::algorithms::greedy::factories::with_error_minimizer;
17//! use dtrees_rs::algorithms::TreeSearchAlgorithm;
18//! use dtrees_rs::reader::data_reader::DataReader;
19//! use std::path::Path;
20//!
21//! let mut cover = DataReader::default().read_file(Path::new("data.txt"))?;
22//! let mut lgdt = with_error_minimizer().max_depth(4).min_support(5).build()?;
23//! lgdt.fit(&mut cover)?;
24//! println!("{}", lgdt.tree());
25//! # Ok::<(), Box<dyn std::error::Error>>(())
26//! ```
27
28// Library code returns text to its caller instead of printing it.
29#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))]
30
31pub mod algorithms;
32pub mod bitsets;
33pub mod caching;
34pub mod cover;
35pub mod globals;
36#[cfg(feature = "cli")]
37pub mod parsers;
38pub mod reader;
39pub mod tree;