Skip to content

set_feature_lengths_class_train_dataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataset_feature_lengths_class_train_dataT_set_feature_lengths_class_train_data🔗

Short description🔗

set_feature_lengths_class_train_dataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataset_feature_lengths_class_train_dataT_set_feature_lengths_class_train_data — Define subfeatures in training data.

Signature🔗

set_feature_lengths_class_train_data( class_train_data ClassTrainDataHandle, number SubFeatureLength, string Names )void SetFeatureLengthsClassTrainData( const HTuple& ClassTrainDataHandle, const HTuple& SubFeatureLength, const HTuple& Names )static void HOperatorSet.SetFeatureLengthsClassTrainData( HTuple classTrainDataHandle, HTuple subFeatureLength, HTuple names )def set_feature_lengths_class_train_data( class_train_data_handle: HHandle, sub_feature_length: Sequence[int], names: Sequence[str] ) -> None

Herror T_set_feature_lengths_class_train_data( const Htuple ClassTrainDataHandle, const Htuple SubFeatureLength, const Htuple Names )

void HClassTrainData::SetFeatureLengthsClassTrainData( const HTuple& SubFeatureLength, const HTuple& Names ) const

void HClassTrainData.SetFeatureLengthsClassTrainData( HTuple subFeatureLength, HTuple names )

Description🔗

set_feature_lengths_class_train_dataSetFeatureLengthsClassTrainData defines subfeatures in the training data in ClassTrainDataHandleclassTrainDataHandleclass_train_data_handle. The subfeatures are defined in SubFeatureLengthsubFeatureLengthsub_feature_length by a set of lengths that groups the previously added columns subsequently into subfeatures. It is not possible to group columns which are not subsequent. The sum over all entries in SubFeatureLengthsubFeatureLengthsub_feature_length must be equal to the number of dimensions set in create_class_train_dataCreateClassTrainData with the parameter NumDimnumDimnum_dim. Optionally, names for all subsets can be defined in Namesnamesnames.

An exemplary situation in which this operator is helpful is described here: Two different data sources are available. Both data sources provide a vector of a certain length. The first data source provides data of length \(n\) and the second of length \(m\). In order to automatically decide which of the data sources is more valuable for a certain classification problem, training data can be created that contains both data sources. E.g., if create_class_train_dataCreateClassTrainData was called with NumDimnumDimnum_dim \(=n+m=w\), then set_feature_lengths_class_train_dataSetFeatureLengthsClassTrainData can be called with [n, m][n, m] in SubFeatureLengthsubFeatureLengthsub_feature_length and [Name1, Name2][Name1, Name2] in Namesnamesnames to describe this situation for a later usage of operators like select_feature_set_knnSelectFeatureSetKnn or select_feature_set_svmSelectFeatureSetSvm. Then the classification problem has to be specified via calls of add_sample_class_train_dataAddSampleClassTrainData, by giving a vector of the first data source and a vector of the second data source as the combined feature vector of length \(w\). The result of the call of select_feature_set_knnSelectFeatureSetKnn would then be either [Name1][Name1] if the first is more relevant, [Name2][Name2] if the second is more relevant or [Name1, Name2][Name1, Name2] if both are necessary.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters🔗

ClassTrainDataHandleclassTrainDataHandleclass_train_data_handle (input_control, state is modified) class_train_data → (handle)HTuple (HHandle)HClassTrainData, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the training data that should be partitioned into subfeatures.

SubFeatureLengthsubFeatureLengthsub_feature_length (input_control) number-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Length of the subfeatures.

Namesnamesnames (input_control) string-array → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Names of the subfeatures.

Example🔗

(HDevelop)

* Find out which of the two features distinguishes two Classes
NameFeature1 := 'Good Feature'
NameFeature2 := 'Bad Feature'
LengthFeature1 := 3
LengthFeature2 := 2
* Create training data
create_class_train_data (LengthFeature1+LengthFeature2,\
  ClassTrainDataHandle)
* Define the features which are in the training data
set_feature_lengths_class_train_data (ClassTrainDataHandle, [LengthFeature1,\
  LengthFeature2], [NameFeature1, NameFeature2])
* Add training data
*                                                          |Feat1| |Feat2|
add_sample_class_train_data (ClassTrainDataHandle, 'row', [1,1,1,  2,1  ], 0)
add_sample_class_train_data (ClassTrainDataHandle, 'row', [2,2,2,  2,1  ], 1)
add_sample_class_train_data (ClassTrainDataHandle, 'row', [1,1,1,  3,4  ], 0)
add_sample_class_train_data (ClassTrainDataHandle, 'row', [2,2,2,  3,4  ], 1)
* Add more data
* ...
* Select the better feature
select_feature_set_knn (ClassTrainDataHandle, 'greedy', [], [], KNNHandle,\
  SelectedFeature, Score)
classify_class_knn (KNNHandle, [1,1,1], Result, Rating)
classify_class_knn (KNNHandle, [2,2,2], Result, Rating)
* Use the classifier
* ...

Result🔗

If the parameters are valid, the operator set_feature_lengths_class_train_dataSetFeatureLengthsClassTrainData returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

create_class_train_dataCreateClassTrainData, add_sample_class_train_dataAddSampleClassTrainData

Possible successors

select_feature_set_knnSelectFeatureSetKnn, select_feature_set_svmSelectFeatureSetSvm, select_feature_set_mlpSelectFeatureSetMlp, select_feature_set_gmmSelectFeatureSetGmm

Module🔗

Foundation