[][src]Struct gbdt::decision_tree::Data

pub struct Data {
    pub feature: Vec<ValueType>,
    pub target: ValueType,
    pub weight: ValueType,
    pub label: ValueType,
    pub residual: ValueType,
    pub initial_guess: ValueType,
}

A training sample or a test sample. You can call new_training_data to generate a training sample, and call new_test_data to generate a test sample.

A training sample can be used as a test sample.

You can also directly generate a data with following guides:

  1. When using the gbdt algorithm for training, you should set the values of feature, weight and label. If Config::initial_guess_enabled is true, you should set the value of initial_guess as well. Other fields can be arbitrary value.

  2. When using the gbdt algorithm for inference, you should set the value of feature. Other fields can be arbitrary value.

  3. When directly using the decision tree for training, only "SquaredError" is supported and you should set the values of feature, weight, label and target. label and target are equal. Other fields can be arbitrary value.

  4. When directly using the decision tree for inference, only "SquaredError" is supported and you should set the values of feature.

Fields

feature: Vec<ValueType>

the vector of features

target: ValueType

the target value of the sample to be fit in one decistion tree. This value is calculated by gradient boost algorithm. If you want to use the decision tree with "SquaredError" directly, set this value with label value

weight: ValueType

sample's weight. Used in training.

label: ValueType

sample's label. Used in training. This value is the actual value of the training sample.

residual: ValueType

used by LAD loss. Calculated by gradient boost algorithm.

initial_guess: ValueType

used by gradient boost. Set this value if Config::initial_guess_enabled is true.

Methods

impl Data[src]

pub fn new_training_data(
    feature: Vec<ValueType>,
    weight: ValueType,
    label: ValueType,
    initial_guess: Option<ValueType>
) -> Self
[src]

Generate a training sample.

feature: the vector of features

weight: sample's weight

label: sample's label

initial_guess: initial prediction for the sample. This value is optional. Set this value if Config::initial_guess_enabled is true.

Example

use gbdt::decision_tree::Data;
let data1 = Data::new_training_data(vec![1.0, 2.0, 3.0],
                                1.0,
                                2.0,
                                Some(0.5));
let data2 = Data::new_training_data(vec![1.0, 2.0, 3.0],
                                1.0,
                                2.0,
                                None);

pub fn new_test_data(feature: Vec<ValueType>, label: Option<ValueType>) -> Self[src]

Generate a test sample.

label: sample's label. It's optional.

Example

use gbdt::decision_tree::Data;
let data1 = Data::new_test_data(vec![1.0, 2.0, 3.0],
                                Some(0.5));
let data2 = Data::new_test_data(vec![1.0, 2.0, 3.0],
                                None);

Trait Implementations

impl Clone for Data[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Data[src]

impl Serialize for Data[src]

impl<'de> Deserialize<'de> for Data[src]

Auto Trait Implementations

impl Send for Data

impl Sync for Data

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]