Skip to main content

Tree

Struct Tree 

Source
pub struct Tree {
Show 19 fields pub num_leaves: usize, pub num_cat: usize, pub split_feature: Vec<i32>, pub split_gain: Vec<f32>, pub threshold: Vec<f64>, pub decision_type: Vec<i8>, pub left_child: Vec<i32>, pub right_child: Vec<i32>, pub leaf_value: Vec<f64>, pub leaf_weight: Vec<f64>, pub leaf_count: Vec<i64>, pub internal_value: Vec<f64>, pub internal_weight: Vec<f64>, pub internal_count: Vec<i64>, pub cat_boundaries: Vec<i32>, pub cat_threshold: Vec<u32>, pub shrinkage: f64, pub leaf_parent: Vec<i32>, pub leaf_depth: Vec<i32>,
}

Fields§

§num_leaves: usize§num_cat: usize§split_feature: Vec<i32>

Input (real) feature index of each internal node.

§split_gain: Vec<f32>§threshold: Vec<f64>

Numerical: the value <= which goes left. Categorical: index into cat_boundaries.

§decision_type: Vec<i8>§left_child: Vec<i32>§right_child: Vec<i32>§leaf_value: Vec<f64>§leaf_weight: Vec<f64>§leaf_count: Vec<i64>§internal_value: Vec<f64>§internal_weight: Vec<f64>§internal_count: Vec<i64>§cat_boundaries: Vec<i32>

num_cat + 1 offsets into cat_threshold.

§cat_threshold: Vec<u32>

Bitsets of category values going left, 32 per word.

§shrinkage: f64§leaf_parent: Vec<i32>

Training only: each leaf’s parent node (-1 for the root).

§leaf_depth: Vec<i32>

Training only: each leaf’s depth (root 0).

Implementations§

Source§

impl Tree

Source

pub fn leaf_index(&self, row: &[f64]) -> usize

The leaf row reaches, as Model::predict_raw_row walks it: row holds raw feature values (NaN missing).

Source§

impl Tree

Source

pub fn new() -> Tree

A single leaf of value 0.

Source

pub fn split_numerical( &mut self, leaf: usize, feature: usize, threshold: f64, default_left: bool, missing: MissingType, children: &SplitChildren, ) -> usize

Tree::Split for a numerical feature; returns the new (right) leaf’s index.

Source

pub fn split_categorical( &mut self, leaf: usize, feature: usize, categories: &[i32], missing: MissingType, children: &SplitChildren, ) -> usize

Tree::SplitCategorical: categories are the category values going left.

Source

pub fn shrink(&mut self, rate: f64)

Tree::Shrinkage.

Source

pub fn add_bias(&mut self, bias: f64)

Tree::AddBias: folds the initial score into the first tree, whose shrinkage LightGBM then writes as 1.

Source

pub fn as_constant(&mut self, value: f64)

Tree::AsConstantTree.

Source

pub fn set_leaf_output(&mut self, leaf: usize, value: f64)

Tree::SetLeafOutput.

Source

pub fn max_depth(&self) -> i32

Depth of the deepest leaf.

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Tree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Tree

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Tree

Auto Trait Implementations§

§

impl Forget for Tree

§

impl Freeze for Tree

§

impl Move for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnsafeUnpin for Tree

§

impl UnwindSafe for Tree

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more