File feature_sampling_without_replacement.hpp

class IFeatureSamplingWithoutReplacementConfig
#include <feature_sampling_without_replacement.hpp>

Defines an interface for all classes that allow to configure a method for sampling features without replacement.

Subclassed by FeatureSamplingWithoutReplacementConfig

Public Functions

inline virtual ~IFeatureSamplingWithoutReplacementConfig()
virtual float32 getSampleSize() const = 0

Returns the fraction of features that are included in a sample.

Returns:

The fraction of features that are included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setSampleSize(float32 sampleSize) = 0

Sets the fraction of features that should be included in a sample.

Parameters:

sampleSize – The fraction of features that should be included in a sample, e.g., a value of 0.6 corresponds to 60 % of the available features. Must be in (0, 1) or 0, if the default sample size floor(log2(numFeatures - 1) + 1) should be used

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

virtual uint32 getMinSamples() const = 0

Returns the minimum number of features that are included in a sample.

Returns:

The minimum number of features that are included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setMinSamples(uint32 minSamples) = 0

Sets the minimum number of features that should be included in a sample.

Parameters:

minSamples – The minimum number of features that should be included in a sample. Must be at least 1

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

virtual uint32 getMaxSamples() const = 0

Returns the maximum number of features that are included in a sample.

Returns:

The maximum number of features that are included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setMaxSamples(uint32 maxSamples) = 0

Sets the maximum number of features that should be included in a sample.

Parameters:

maxSamples – The maximum number of features that should be included in a sample. Must be at the value returned by getMaxSamples or 0, if the number of features should not be restricted

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

virtual uint32 getNumRetained() const = 0

Returns the number of trailing features that are always included in a sample.

Returns:

The number of trailing features that are always included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setNumRetained(uint32 numRetained) = 0

Sets the number fo trailing features that should always be included in a sample.

Parameters:

numRetained – The number of trailing features that should always be included in a sample. Must be at least 0

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

class FeatureSamplingWithoutReplacementConfig : public IFeatureSamplingConfig, public IFeatureSamplingWithoutReplacementConfig
#include <feature_sampling_without_replacement.hpp>

Allows to configure a method for sampling features without replacement.

Public Functions

FeatureSamplingWithoutReplacementConfig(ReadableProperty<RNGConfig> rngConfig)
Parameters:

rngConfig – A ReadableProperty that allows to access the RNGConfig that stores the configuration of random number generators

virtual float32 getSampleSize() const override

Returns the fraction of features that are included in a sample.

Returns:

The fraction of features that are included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setSampleSize(float32 sampleSize) override

Sets the fraction of features that should be included in a sample.

Parameters:

sampleSize – The fraction of features that should be included in a sample, e.g., a value of 0.6 corresponds to 60 % of the available features. Must be in (0, 1) or 0, if the default sample size floor(log2(numFeatures - 1) + 1) should be used

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

virtual uint32 getMinSamples() const override

Returns the minimum number of features that are included in a sample.

Returns:

The minimum number of features that are included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setMinSamples(uint32 minSamples) override

Sets the minimum number of features that should be included in a sample.

Parameters:

minSamples – The minimum number of features that should be included in a sample. Must be at least 1

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

virtual uint32 getMaxSamples() const override

Returns the maximum number of features that are included in a sample.

Returns:

The maximum number of features that are included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setMaxSamples(uint32 maxSamples) override

Sets the maximum number of features that should be included in a sample.

Parameters:

maxSamples – The maximum number of features that should be included in a sample. Must be at the value returned by getMaxSamples or 0, if the number of features should not be restricted

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

virtual uint32 getNumRetained() const override

Returns the number of trailing features that are always included in a sample.

Returns:

The number of trailing features that are always included in a sample

virtual IFeatureSamplingWithoutReplacementConfig &setNumRetained(uint32 numRetained) override

Sets the number fo trailing features that should always be included in a sample.

Parameters:

numRetained – The number of trailing features that should always be included in a sample. Must be at least 0

Returns:

A reference to an object of type IFeatureSamplingWithoutReplacementConfig that allows further configuration of the method for sampling features

virtual std::unique_ptr<IFeatureSamplingFactory> createFeatureSamplingFactory(const IFeatureMatrix &featureMatrix) const override

Creates and returns a new object of type IFeatureSamplingFactory according to the specified configuration.

Parameters:

featureMatrix – A reference to an object of type IFeatureMatrix that provides access to the features of the training examples

Returns:

An unique pointer to an object of type IFeatureSamplingFactory that has been created

virtual bool isSamplingUsed() const override

Returns whether feature sampling is used or not.

Returns:

True, if feature sampling is used, false otherwise

Private Members

const ReadableProperty<RNGConfig> rngConfig_
float32 sampleSize_
uint32 minSamples_
uint32 maxSamples_
uint32 numRetained_