Into

Modules

Documentation

classPiiDecisionStump

#include <PiiDecisionStump.h>

A primitive learner that works by thresholding a single feature.

Inherits PiiClassifier< SampleSet >, PiiLearningAlgorithm< SampleSet >

Description

A decision stump is trained with weighted samples. The learning algorithm classifies the sample set to two classes by thresholding just one of the features values so that the weighted error is minimized.

Traditionally, decision stumps are used binary classification problems. This class implements a more general multi-class decision stump that selects not only the optimal threshold but also two classes that are optimally separated by the threshold.

Public types

typedef PiiSampleSet::Traits< SampleSet >::ConstFeatureIterator
typedef PiiSampleSet::Traits< SampleSet >::FeatureType

Constructors and destructor

Public member functions

virtual PiiClassification::LearnerCapabilities

Returns WeightedLearner.

virtual double
(
  • ConstFeatureIterator sample
)

Returns #leftLabel() if the selected feature" is less than or equal to threshold() and #rightLabel() otherwise.

virtual bool

Returns true if the algorithm has converged (found an optimal solution) and false otherwise.

virtual void
(
  • const SampleSet & samples
  • const QVector< double > & labels
  • const QVector< double > & weights
)

Finds the feature that best separates the two classes present in samples and an optimal threshold for it.

double
double
int

Returns the index of the feature that was chosen as the optimal one by learn().

void
(
  • double leftLabel
)
void
(
  • double rightLabel
)
void
(
  • int feature
)

Sets the selected feature to feature.

void
(
  • FeatureType threshold
)
FeatureType

Returns the optimal threshold value for the selected feature.

Function details

  • PiiDecisionStump

    ()
  • virtual PiiClassification::LearnerCapabilities capabilities

    ()
    [virtual]

    Returns WeightedLearner.

    Reimplemented from PiiLearningAlgorithm.

  • virtual double classify

    (
    • ConstFeatureIterator sample
    )
    [virtual]

    Returns #leftLabel() if the selected feature" is less than or equal to threshold() and #rightLabel() otherwise.

    Reimplemented from PiiClassifier.

  • virtual bool converged

    ()
    [virtual]

    Returns true if the algorithm has converged (found an optimal solution) and false otherwise.

    Reimplemented from PiiLearningAlgorithm.

  • virtual void learn

    (
    • const SampleSet & samples
    • const QVector< double > & labels
    • const QVector< double > & weights
    )
    [virtual]

    Finds the feature that best separates the two classes present in samples and an optimal threshold for it.

    Reimplemented from PiiLearningAlgorithm.

  • double leftLabel

    ()
  • double rightLabel

    ()
  • int selectedFeature

    ()

    Returns the index of the feature that was chosen as the optimal one by learn().

  • void setLeftLabel

    (
    • double leftLabel
    )
  • void setRightLabel

    (
    • double rightLabel
    )
  • void setSelectedFeature

    (
    • int feature
    )

    Sets the selected feature to feature.

    If the selected feature is set manually, one must ensure it won't exceed the length of the incoming feature vectors.

  • void setThreshold

    (
    • FeatureType threshold
    )
  • FeatureType threshold

    ()

    Returns the optimal threshold value for the selected feature.

Notes (0)

Add a note

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