set_feature_lengths_class_train_dataT_set_feature_lengths_class_train_dataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataset_feature_lengths_class_train_data (Operator)

Name

set_feature_lengths_class_train_dataT_set_feature_lengths_class_train_dataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataset_feature_lengths_class_train_data — Define subfeatures in training data.

Signature

set_feature_lengths_class_train_data( : : ClassTrainDataHandle, SubFeatureLength, Names : )

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

void SetFeatureLengthsClassTrainData(const HTuple& ClassTrainDataHandle, const HTuple& SubFeatureLength, const HTuple& Names)

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

static void HOperatorSet.SetFeatureLengthsClassTrainData(HTuple classTrainDataHandle, HTuple subFeatureLength, HTuple names)

void HClassTrainData.SetFeatureLengthsClassTrainData(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

Description

set_feature_lengths_class_train_dataset_feature_lengths_class_train_dataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataset_feature_lengths_class_train_data defines subfeatures in the training data in ClassTrainDataHandleClassTrainDataHandleClassTrainDataHandleClassTrainDataHandleclassTrainDataHandleclass_train_data_handle. The subfeatures are defined in SubFeatureLengthSubFeatureLengthSubFeatureLengthSubFeatureLengthsubFeatureLengthsub_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 SubFeatureLengthSubFeatureLengthSubFeatureLengthSubFeatureLengthsubFeatureLengthsub_feature_length must be equal to the number of dimensions set in create_class_train_datacreate_class_train_dataCreateClassTrainDataCreateClassTrainDataCreateClassTrainDatacreate_class_train_data with the parameter NumDim. Optionally, names for all subsets can be defined in NamesNamesNamesNamesnamesnames.

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_datacreate_class_train_dataCreateClassTrainDataCreateClassTrainDataCreateClassTrainDatacreate_class_train_data was called with NumDim =n+m=w, then set_feature_lengths_class_train_dataset_feature_lengths_class_train_dataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataset_feature_lengths_class_train_data can be called with [n,m] in SubFeatureLengthSubFeatureLengthSubFeatureLengthSubFeatureLengthsubFeatureLengthsub_feature_length and [Name1, Name2] in NamesNamesNamesNamesnamesnames to describe this situation for a later usage of operators like select_feature_set_knnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnnSelectFeatureSetKnnselect_feature_set_knn or select_feature_set_svmselect_feature_set_svmSelectFeatureSetSvmSelectFeatureSetSvmSelectFeatureSetSvmselect_feature_set_svm. Then the classification problem has to be specified via calls of add_sample_class_train_dataadd_sample_class_train_dataAddSampleClassTrainDataAddSampleClassTrainDataAddSampleClassTrainDataadd_sample_class_train_data, 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_knnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnnSelectFeatureSetKnnselect_feature_set_knn would then be either [Name1] if the first is more relevant, [Name2] if the second is more relevant or [Name1, Name2] if both are necessary.

Execution Information

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

ClassTrainDataHandleClassTrainDataHandleClassTrainDataHandleClassTrainDataHandleclassTrainDataHandleclass_train_data_handle (input_control, state is modified)  class_train_data HClassTrainData, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

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

SubFeatureLengthSubFeatureLengthSubFeatureLengthSubFeatureLengthsubFeatureLengthsub_feature_length (input_control)  number-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Length of the subfeatures.

NamesNamesNamesNamesnamesnames (input_control)  string-array HTupleSequence[str]HTupleHtuple (string) (string) (HString) (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_dataset_feature_lengths_class_train_dataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataSetFeatureLengthsClassTrainDataset_feature_lengths_class_train_data returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Possible Predecessors

create_class_train_datacreate_class_train_dataCreateClassTrainDataCreateClassTrainDataCreateClassTrainDatacreate_class_train_data, add_sample_class_train_dataadd_sample_class_train_dataAddSampleClassTrainDataAddSampleClassTrainDataAddSampleClassTrainDataadd_sample_class_train_data

Possible Successors

select_feature_set_knnselect_feature_set_knnSelectFeatureSetKnnSelectFeatureSetKnnSelectFeatureSetKnnselect_feature_set_knn, select_feature_set_svmselect_feature_set_svmSelectFeatureSetSvmSelectFeatureSetSvmSelectFeatureSetSvmselect_feature_set_svm, select_feature_set_mlpselect_feature_set_mlpSelectFeatureSetMlpSelectFeatureSetMlpSelectFeatureSetMlpselect_feature_set_mlp, select_feature_set_gmmselect_feature_set_gmmSelectFeatureSetGmmSelectFeatureSetGmmSelectFeatureSetGmmselect_feature_set_gmm

Module

Foundation