Struct gbdt::decision_tree::Data

source ·
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§

source§

impl Data

source

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

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

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

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§

source§

impl Clone for Data

source§

fn clone(&self) -> Data

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Data

source§

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

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

impl<'de> Deserialize<'de> for Data

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Data

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Data

§

impl Send for Data

§

impl Sync for Data

§

impl Unpin for Data

§

impl UnwindSafe for Data

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

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