pub struct Tikz<'a, F: Float, L: Label + Debug> { /* private fields */ }
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§
Source§impl<'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§
impl<'a, F: Float, L: Label + Debug> StructuralPartialEq for Tikz<'a, F, L>
Auto Trait Implementations§
impl<'a, F, L> Freeze for Tikz<'a, F, L>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.