Into

Modules

Documentation

classPiiVectorQuantizerOperation

#include <PiiVectorQuantizerOperation.h>

A superclass for classifier operations that use classifiers derived from PiiVectorQuantizer.

Inherits PiiClassifierOperation

Inherited by PiiKnnClassifierOperation, PiiSomOperation

Description

This class adds support for run-time changeable distance measures to the classifier operation.

Inputs

boundariesan optional input that marks the boundaries of multiple feature vectors in a compound feature vector. This input is usually used in conjunction with PiiFeatureCombiner. If this input is connected, a multi-feature distance measure can used in classification (PiiMatrix<int>).

Outputs

model indexthe index of the closest code vector (int). This value equals classification if classLabels are not set.
distancedistance to the closest code vector. (double)

Properties

QVariantList

Class labels for code vectors.

The mode of combining the distances calculated by different distance measures.

Set the distance measure.

Set many distance measures.

QVariantList

Weights assigned to distance measures, if many are used.

The model samples as a PiiVariant.

double

Set a distance threshold for rejecting samples.

Constructors and destructor

(
  • PiiClassification::LearnerCapabilities capabilities
)

Public member functions

QVariantList
QVariantList
( )
double
void
(
  • const QVariantList & labels
)
void
void
( )
void
void
(
  • const QVariantList & distanceWeights
)
void
( )
void
(
  • double rejectThreshold
)

Protected member functions

Returns a pointer to the boundary input.

template<class SampleSet>
void
( )

Configure classifier for running.

template<class SampleSet>
double
(
  • PiiVectorQuantizer< SampleSet > & classifier
  • int * vectorIndex = 0
  • double * distance = 0
)

Reads features from the features input, configures multi-feature boundaries if needed, finds the closest match for the features just read, and returns the index of the closest vector in the model sample set.

template<class Measure>
Measure *

Create an instance of name as Measure.

Returns a pointer to the distance output.

double
(
  • int index
)

Returns the class label corresponding to the sample at index.

(
  • PiiClassification::LearnerCapabilities capabilities
)
template<class SampleSet>
void
( )

Creates an instance of a distance measure as specified by the distanceMeasure property.

template<class SampleSet>
void
( )

Configures classifier so that its distance measure is aware of multi-feature boundaries.

template<class SampleSet>
void
( )

Checks that the models variant is of correct type, and reconfigures classifier with them.

Returns a pointer to the vector index output.

Property details

  • QVariantList classLabels

    [read, write]

    Class labels for code vectors.

    If this list is non-empty, the classification output will emit the label corresponding to the closest code vector instead of the index of the code vector. Otherwise the classification and vector index outputs will both emit the index of the closest code vector.

  • PiiClassification::DistanceCombinationMode distanceCombinationMode

    [read, write]

    The mode of combining the distances calculated by different distance measures.

  • QString distanceMeasure

    [read, write]

    Set the distance measure.

    Use the resource name in the resource database as a key. Note that distance measures are registered to the resource database as template instances, but template arguments should not be explicitly given here. If no resource matching the given name is found in the resource database, setting this property does nothing. The default distance measure is PiiSquaredGeometricDistance.

     PiiOperation* pClassifier = engine.createOperation("PiiKnnClassifier<float>");
     // This will create an instance of PiiHistogramIntersection<float>
     classifier->setProperty("distanceMeasure", "PiiHistogramIntersection");
     // Explicitly creating a one-element list has the same same effect
     classifier->setProperty("distanceMeasures", QStringList() << "PiiHistogramIntersection");
    
  • QStringList distanceMeasures

    [read, write]

    Set many distance measures.

    Multiple different distance measures may be needed if input samples are composed of many feature vectors. Assume your feature vectors actually consist of two concatenated vectors (see PiiFeatureCombiner). You intend to use histogram intersection for the first and log-likelihood for the other. Here's how:

     classifier->setProperty("distanceMeasures",
                             QStringList() << "PiiHistogramIntersection" << "PiiLogLikelihood");
    

    If multiple distance measures are given, distanceMeasure will be set to "PiiMultiFeatureDistance".

  • QVariantList distanceWeights

    [read, write]

    Weights assigned to distance measures, if many are used.

  • PiiVariant models

    [read, write]

    The model samples as a PiiVariant.

    The variant will usually hold a PiiMatrix whose data type equals the type of the operation. For example, PiiSomOperation<double> will have a PiiMatrix<double> as its code book. Subclasses are however free to use any suitable data structure to represent the code book.

  • double rejectThreshold

    [read, write]

    Set a distance threshold for rejecting samples.

    If the distance of an unknown sample to the closest code vector is above this threshold, the sample will be rejected and classified as minus one. The default value is INFINITY.

Function details

  • PiiVectorQuantizerOperation

    (
    • PiiClassification::LearnerCapabilities capabilities
    )
    [protected]
  • ~PiiVectorQuantizerOperation

    ()
  • QVariantList classLabels

    ()
  • PiiClassification::DistanceCombinationMode distanceCombinationMode

    ()
  • QString distanceMeasure

    ()
  • QStringList distanceMeasures

    ()
  • QVariantList distanceWeights

    ()
  • PiiVariant models

    ()
  • double rejectThreshold

    ()
  • void setClassLabels

    (
    • const QVariantList & labels
    )
  • void setDistanceCombinationMode

    ( )
  • void setDistanceMeasure

    ( )
  • void setDistanceMeasures

    ( )
  • void setDistanceWeights

    (
    • const QVariantList & distanceWeights
    )
  • void setModels

    ( )
  • void setRejectThreshold

    (
    • double rejectThreshold
    )
  • PiiInputSocket * boundaryInput

    ()
    [protected]

    Returns a pointer to the boundary input.

  • template<class SampleSet>

    void check

    ( )
    [protected]

    Configure classifier for running.

    This function must be called by a subclass' implementation of the check() function. This function configures classifier with the samples given as the models property, and creates an instance of the requested distance measure.

    Exceptions
    PiiExecutionException&

    if setting the model samples or the distance measure fails.

  • template<class SampleSet>

    double classify

    (
    • PiiVectorQuantizer< SampleSet > & classifier
    • int * vectorIndex = 0
    • double * distance = 0
    )
    [protected]

    Reads features from the features input, configures multi-feature boundaries if needed, finds the closest match for the features just read, and returns the index of the closest vector in the model sample set.

    If classLabels is non-empty, returns the class label corresponding to the index of the closest sample. This function also sends the distance to the closest sample and its index.

    Exceptions
    PiiExecutionException&

    if the features are of incorrect type or size.

  • template<class Measure>

    Measure * createDistanceMeasure

    ( )
    [protected]

    Create an instance of name as Measure.

    Exceptions
    PiiExecutionException&

    if the resource database doesn't contain the named resource, or it is not instantiable as Measure.

  • PiiOutputSocket * distanceOutput

    ()
    [protected]

    Returns a pointer to the distance output.

  • double labelForIndex

    (
    • int index
    )
    [protected]

    Returns the class label corresponding to the sample at index.

    If the label list is empty, returns index (or NaN if index is -1). If there is no label for index, returns NAN.

  • template<class SampleSet>

    void setDistanceMeasure

    ( )
    [protected]

    Creates an instance of a distance measure as specified by the distanceMeasure property.

    If there are many distance measures, creates a PiiMultiFeatureDistance and appends all requrested distance measures to it.

    Exceptions
    PiiExecutionException&

    if the distance measures cannot be created.

  • template<class SampleSet>

    void setFeatureBoundaries

    ( )
    [protected]

    Configures classifier so that its distance measure is aware of multi-feature boundaries.

    Does nothing if the distance measure is not a PiiMultiFeatureDistance or the boundaries input is not connected.

    Exceptions
    PiiExecutionException&

    if the boundary input doesn't contain a PiiMatrix<int>.

  • template<class SampleSet>

    void setModels

    ( )
    [protected]

    Checks that the models variant is of correct type, and reconfigures classifier with them.

    Exceptions
    PiiExecutionException&

    if the type of the variant is incorrect

  • PiiOutputSocket * vectorIndexOutput

    ()
    [protected]

    Returns a pointer to the vector index output.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.