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:
-
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.
-
When using the gbdt algorithm for inference, you should set the value of feature. Other fields can be arbitrary value.
-
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
andtarget
are equal. Other fields can be arbitrary value. -
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
sourceimpl Data
impl Data
sourcepub fn new_training_data(
feature: Vec<ValueType>,
weight: ValueType,
label: ValueType,
initial_guess: Option<ValueType>
) -> Self
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);
sourcepub fn new_test_data(feature: Vec<ValueType>, label: Option<ValueType>) -> Self
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);