Skip to content

add_sample_class_gmmAddSampleClassGmmAddSampleClassGmmadd_sample_class_gmmT_add_sample_class_gmm🔗

Short description🔗

add_sample_class_gmmAddSampleClassGmmAddSampleClassGmmadd_sample_class_gmmT_add_sample_class_gmm — Add a training sample to the training data of a Gaussian Mixture Model.

Signature🔗

add_sample_class_gmm( class_gmm GMMHandle, real Features, number ClassID, real Randomize )void AddSampleClassGmm( const HTuple& GMMHandle, const HTuple& Features, const HTuple& ClassID, const HTuple& Randomize )static void HOperatorSet.AddSampleClassGmm( HTuple GMMHandle, HTuple features, HTuple classID, HTuple randomize )def add_sample_class_gmm( gmmhandle: HHandle, features: Sequence[float], class_id: int, randomize: float ) -> None

Herror T_add_sample_class_gmm( const Htuple GMMHandle, const Htuple Features, const Htuple ClassID, const Htuple Randomize )

void HClassGmm::AddSampleClassGmm( const HTuple& Features, Hlong ClassID, double Randomize ) const

void HClassGmm.AddSampleClassGmm( HTuple features, int classID, double randomize )

Description🔗

add_sample_class_gmmAddSampleClassGmm adds a training sample to the Gaussian Mixture Model (GMM) given by GMMHandleGMMHandlegmmhandle. The training sample is given by Featuresfeaturesfeatures and ClassIDclassIDclass_id. Featuresfeaturesfeatures is the feature vector of the sample, and consequently must be a real vector of length NumDimnumDimnum_dim, as specified in create_class_gmmCreateClassGmm. ClassIDclassIDclass_id is the class of the sample, an integer between 0 and NumClassesnumClassesnum_classes-1 (set in create_class_gmmCreateClassGmm).

In the special case where the feature vectors are of integer type, they are lying in the feature space in a grid with step width 1.0. For example, the RGB feature vectors typically used for color classification are triples having integer values between 0 and 255 for each of their components. In fact, there might be even several feature vectors representing the same point. When training a GMM with such data, the training algorithm may tend to align the modeled Gaussians along linearly dependent lines or planes of data that are parallel to the grid dimensions. If the number of Centerscenterscenters returned by train_class_gmmTrainClassGmm is unusually high, this indicates such a behavior of the algorithm. The parameter Randomizerandomizerandomize can be used to handle such undesired effects. If \(\textrm{Randomize} > 0.0\), random Gaussian noise with mean 0 and standard deviation Randomizerandomizerandomize is added to each component of the training data vectors, and the transformed training data is stored in the GMM. For values of Randomizerandomizerandomize \(\le\) 1.0, the randomized data will look like small clouds around the grid points, which does not improve the properties of the data cloud. For values of Randomizerandomizerandomize

2.0, the randomization might have a too strong influence on the resulting GMM. For integer feature vectors, a value of Randomizerandomizerandomize between 1.5 and 2.0 is recommended, which transforms the integer data into homogeneous clouds, without modifying its general form in the feature space. If the data has been created from integer data by scaling, the same problem may occur. Here, Randomizerandomizerandomize must be scaled with the same scale factor that was used to scale the original data.

Before the GMM can be trained with train_class_gmmTrainClassGmm, all training samples must be added to the GMM with add_sample_class_gmmAddSampleClassGmm.

The number of currently stored training samples can be queried with get_sample_num_class_gmmGetSampleNumClassGmm. Stored training samples can be read out again with get_sample_class_gmmGetSampleClassGmm.

Normally, it is useful to save the training samples in a file with write_samples_class_gmmWriteSamplesClassGmm to facilitate reusing the samples, and to facilitate that, if necessary, new training samples can be added to the data set, and hence to facilitate that a newly created GMM can be trained anew with the extended data set.

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🔗

GMMHandleGMMHandlegmmhandle (input_control, state is modified) class_gmm → (handle)HTuple (HHandle)HClassGmm, HTuple (IntPtr)HHandleHtuple (handle)

GMM handle.

Featuresfeaturesfeatures (input_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Feature vector of the training sample to be stored.

ClassIDclassIDclass_id (input_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Class of the training sample to be stored.

Randomizerandomizerandomize (input_control) real → (real)HTuple (double)HTuple (double)floatHtuple (double)

Standard deviation of the Gaussian noise added to the training data.

Default: 0.00.0
Suggested values: 0.0, 1.5, 2.00.0, 1.5, 2.0
Restriction: Randomize >= 0.0

Result🔗

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

Combinations with other operators🔗

Combinations

Possible predecessors

create_class_gmmCreateClassGmm

Possible successors

train_class_gmmTrainClassGmm, write_samples_class_gmmWriteSamplesClassGmm

Alternatives

read_samples_class_gmmReadSamplesClassGmm, add_samples_image_class_gmmAddSamplesImageClassGmm

See also

clear_samples_class_gmmClearSamplesClassGmm, get_sample_num_class_gmmGetSampleNumClassGmm, get_sample_class_gmmGetSampleClassGmm

Module🔗

Foundation