pub trait TrainDataConst {
Show 35 methods fn as_raw_TrainData(&self) -> *const c_void; fn get_layout(&self) -> Result<i32> { ... } fn get_n_train_samples(&self) -> Result<i32> { ... } fn get_n_test_samples(&self) -> Result<i32> { ... } fn get_n_samples(&self) -> Result<i32> { ... } fn get_n_vars(&self) -> Result<i32> { ... } fn get_n_all_vars(&self) -> Result<i32> { ... } fn get_sample(
        &self,
        var_idx: &dyn ToInputArray,
        sidx: i32,
        buf: &mut f32
    ) -> Result<()> { ... } fn get_samples(&self) -> Result<Mat> { ... } fn get_missing(&self) -> Result<Mat> { ... } fn get_train_samples(
        &self,
        layout: i32,
        compress_samples: bool,
        compress_vars: bool
    ) -> Result<Mat> { ... } fn get_train_responses(&self) -> Result<Mat> { ... } fn get_train_norm_cat_responses(&self) -> Result<Mat> { ... } fn get_test_responses(&self) -> Result<Mat> { ... } fn get_test_norm_cat_responses(&self) -> Result<Mat> { ... } fn get_responses(&self) -> Result<Mat> { ... } fn get_norm_cat_responses(&self) -> Result<Mat> { ... } fn get_sample_weights(&self) -> Result<Mat> { ... } fn get_train_sample_weights(&self) -> Result<Mat> { ... } fn get_test_sample_weights(&self) -> Result<Mat> { ... } fn get_var_idx(&self) -> Result<Mat> { ... } fn get_var_type(&self) -> Result<Mat> { ... } fn get_var_symbol_flags(&self) -> Result<Mat> { ... } fn get_response_type(&self) -> Result<i32> { ... } fn get_train_sample_idx(&self) -> Result<Mat> { ... } fn get_test_sample_idx(&self) -> Result<Mat> { ... } fn get_values(
        &self,
        vi: i32,
        sidx: &dyn ToInputArray,
        values: &mut f32
    ) -> Result<()> { ... } fn get_norm_cat_values(
        &self,
        vi: i32,
        sidx: &dyn ToInputArray,
        values: &mut i32
    ) -> Result<()> { ... } fn get_default_subst_values(&self) -> Result<Mat> { ... } fn get_cat_count(&self, vi: i32) -> Result<i32> { ... } fn get_class_labels(&self) -> Result<Mat> { ... } fn get_cat_ofs(&self) -> Result<Mat> { ... } fn get_cat_map(&self) -> Result<Mat> { ... } fn get_test_samples(&self) -> Result<Mat> { ... } fn get_names(&self, names: &mut Vector<String>) -> Result<()> { ... }
}
Expand description

Class encapsulating training data.

Please note that the class only specifies the interface of training data, but not implementation. All the statistical model classes in ml module accepts Ptr<TrainData> as parameter. In other words, you can create your own class derived from TrainData and pass smart pointer to the instance of this class into StatModel::train.

See also

@ref ml_intro_data

Required Methods

Provided Methods

Returns matrix of train samples

Parameters
  • layout: The requested layout. If it’s different from the initial one, the matrix is transposed. See ml::SampleTypes.
  • compressSamples: if true, the function returns only the training samples (specified by sampleIdx)
  • compressVars: if true, the function returns the shorter training samples, containing only the active variables.

In current implementation the function tries to avoid physical data copying and returns the matrix stored inside TrainData (unless the transposition or compression is needed).

C++ default parameters
  • layout: ROW_SAMPLE
  • compress_samples: true
  • compress_vars: true

Returns the vector of responses

The function returns ordered or the original categorical responses. Usually it’s used in regression algorithms.

Returns the vector of normalized categorical responses

The function returns vector of responses. Each response is integer from 0 to <number of classes>-1. The actual label value can be retrieved then from the class label vector, see TrainData::getClassLabels.

Returns the vector of class labels

The function returns vector of unique labels occurred in the responses.

Returns matrix of test samples

Returns vector of symbolic names captured in loadFromCSV()

Implementors