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

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.

Implementations

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);

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.