Struct linfa_trees::Tikz
source · [−]Expand description
Struct to print a fitted decision tree in Tex using tikz and forest.
There are two settable parameters:
legend
: if true, a box with the names of the split features will appear in the top right of the treecomplete
: if true, a complete and standalone Tex document will be generated; otherwise the result will an embeddable Tex tree.
Usage
use linfa::prelude::*;
use linfa_datasets;
use linfa_trees::DecisionTree;
// Load dataset
let dataset = linfa_datasets::iris();
// Fit the tree
let tree = DecisionTree::params().fit(&dataset).unwrap();
// Export to tikz
let tikz = tree.export_to_tikz().with_legend();
let latex_tree = tikz.to_string();
// Now you can write latex_tree to the preferred destination
Implementations
sourceimpl<'a, F: Float, L: Debug + Label> Tikz<'a, F, L>
impl<'a, F: Float, L: Debug + Label> Tikz<'a, F, L>
sourcepub fn new(tree: &'a DecisionTree<F, L>) -> Self
pub fn new(tree: &'a DecisionTree<F, L>) -> Self
Creates a new Tikz structure for the decision tree with the following default parameters:
legend=false
complete=true
sourcepub fn complete(self, complete: bool) -> Self
pub fn complete(self, complete: bool) -> Self
Whether a complete Tex document should be generated
sourcepub fn with_legend(self) -> Self
pub fn with_legend(self) -> Self
Add a legend to the generated tree
Trait Implementations
sourceimpl<'a, F: PartialEq + Float, L: PartialEq + Label + Debug> PartialEq<Tikz<'a, F, L>> for Tikz<'a, F, L>
impl<'a, F: PartialEq + Float, L: PartialEq + Label + Debug> PartialEq<Tikz<'a, F, L>> for Tikz<'a, F, L>
impl<'a, F: Float, L: Label + Debug> StructuralPartialEq for Tikz<'a, F, L>
Auto Trait Implementations
impl<'a, F, L> RefUnwindSafe for Tikz<'a, F, L> where
F: RefUnwindSafe,
L: RefUnwindSafe,
impl<'a, F, L> Send for Tikz<'a, F, L> where
L: Sync,
impl<'a, F, L> Sync for Tikz<'a, F, L> where
L: Sync,
impl<'a, F, L> Unpin for Tikz<'a, F, L>
impl<'a, F, L> UnwindSafe for Tikz<'a, F, L> where
F: RefUnwindSafe,
L: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more