classPiiSampleRandomizer
#include <PiiSampleRandomizer.h>
An operation that stores names of samples belonging to N different classes.
Inherits PiiDefaultOperation
Description
On each iteration it randomly selects a sample from one of the classes and outputs its name and class index.
Inputs
Outputs
Properties
|
QVariantList
|
Relative weights for each of the classes. |
|
int
|
The zero-based index of the next sample to be emitted. |
|
int
|
The maximum number of sample names the source will emit. |
|
bool
|
Set this property to true if you want the sample selection to be random. |
|
QVariantList
|
The names of samples for each class. |
Constructors and destructor
Public member functions
|
QVariantList
|
( )
|
|
int
|
|
|
int
|
( )
|
|
bool
|
( )
|
|
QVariantList
|
( )
|
|
void
|
(
|
|
void
|
(
|
|
void
|
(
|
|
void
|
(
|
Protected member functions
|
virtual void
|
(
Checks the operation for execution. |
|
virtual void
|
( )
Executes one round of processing. |
Property details
-
QVariantList classWeights
[read, write]Relative weights for each of the classes.
The random selection of each class will be weighted according to its relative weight in this list. To set class 1 twice as likely as class 0, do this:
randomizer->setProperty("classWeights", QVariantList() << 1.0 << 2.0);
If
classWeightsis an empty list, the operation goes sequentially through all classes and emits one sample from each. -
int currentSampleIndex
[read]The zero-based index of the next sample to be emitted.
-
int maxSamples
[read, write]The maximum number of sample names the source will emit.
Zero means eternally. This property is ineffective if
triggeris connected. The default is zero. -
bool randomSampling
[read, write]Set this property to true if you want the sample selection to be random.
The operation still selects the class randomly, but goes sequentially through the sample names by default.
-
QVariantList sampleNames
[read, write]The names of samples for each class.
This list should hold one to N-1 entries, each of which represents the names of samples that belong to the class at that index. Class names are stored as a QStringList.
randomizer->setProperty("sampleNames", QVariantList() << (QStringList() << "Orange1" << "Orange2" << "Orange3") << (QStringList() << "Apple1" << "Apple2"));
Function details
-
PiiSampleRandomizer
() -
QVariantList classWeights
() -
int currentSampleIndex
() -
int maxSamples
() -
bool randomSampling
() -
QVariantList sampleNames
() -
void setClassWeights
(- const QVariantList & classWeights
-
void setMaxSamples
(- int maxSamples
-
void setRandomSampling
(- bool randomSampling
-
void setSampleNames
(- const QVariantList & sampleNames
-
virtual void check
(- bool reset
[protected, virtual]Checks the operation for execution.
This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.
If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.
Reimplemented from PiiDefaultOperation.
-
virtual void process
()[protected, virtual]Executes one round of processing.
This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.
Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().
Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns
Running.Exceptions
- PiiExecutionException
-
whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.
Reimplemented from PiiDefaultOperation.
Add a note
Not a single note added yet. Be the first, add yours.