Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

PatternSource Class Reference

The abstract base class for pattern sources such are PatternSet. More...

#include <patternset.h>

Inheritance diagram for PatternSource:

ArrayTrainSet PatternSet List of all members.

Public Types

enum  psetflags

Public Methods

 PatternSource (const PatternSource &orig)
virtual void print (FILE *out=stdout) const
virtual double input (int p, int i) const
virtual double output (int p, int j) const
virtual int getClass (int p) const
virtual void recombine (int startp=-1, int endp=-1)
virtual void recombine2 (int startp=-1, int endp=-1)
virtual void copy (const PatternSource &other, int startp=-1, int endp=-1)
void operator= (const PatternSource &other)
const String & name () const
void setName (const String &name)
void join (const PatternSource &a, const PatternSource &b)
void split (PatternSource &a, PatternSource &b, double ratio) const
void filter (const PatternSource &source, const String &bits)
int classes () const
Array< int > countClasses () const
void check () const

Public Attributes

int inputs
int outputs
int patterns

Protected Methods

virtual void make (int patterns, int inputs, int outputs)

Protected Attributes

String mName

Detailed Description

The abstract base class for pattern sources such are PatternSet.

Definition at line 45 of file patternset.h.


Member Enumeration Documentation

enum psetflags
 

Pattern set flags.

Definition at line 153 of file patternset.h.


Constructor & Destructor Documentation

PatternSource const PatternSource &    orig
 

Inheritor's copy constructor should call this.

Definition at line 45 of file patternset.cc.

References inputs, mName, outputs, and patterns.


Member Function Documentation

void check  
 

Implementation for Object.

Reimplemented in PatternSet.

Definition at line 212 of file patternset.cc.

References inputs, outputs, and patterns.

Referenced by PatternSet::check().

int classes   const [inline]
 

Returns the number of output classes in the set.

This assumes that the pattern set is for a classification task. For each class there is one output. But, if there are only two classes, they can be represented by just one output.

Definition at line 127 of file patternset.h.

References outputs.

Referenced by countClasses().

void copy const PatternSource &    other,
int    startp = -1,
int    endp = -1
[virtual]
 

Copies a range from another training set.

Parameters:
startp  OPTIONAL Lower index of copying range.
endp  OPTIONAL Upper index of copying range.

Definition at line 75 of file patternset.cc.

References input(), inputs, make(), output(), outputs, and patterns.

Referenced by PatternSet::copy(), join(), operator=(), and split().

Array< int > countClasses  
 

Returns the number of instances for each class.

This works only for patterns sets used in classification tasks where there is one output for each class (or just one output in case of two classes). It is assumed that when a pattern belongs to a certain class with index c, the c:th input variable is set to value >0.5. Otherwise it is set to value <0.5.

Definition at line 201 of file patternset.cc.

References classes(), getClass(), and patterns.

void filter const PatternSource &    source,
const String &    bits
 

Copies another set by filtering the input variables with bit string mask containing characters "0" and "1".

If bits string is null (len==0), all inputs will be taken.

Definition at line 163 of file patternset.cc.

References input(), inputs, make(), output(), outputs, and patterns.

int getClass int    p const [virtual]
 

Returns the output class index for pattern p (the index of the highest output).

Definition at line 58 of file patternset.cc.

References output(), and outputs.

Referenced by countClasses(), and Learner::testClassify().

virtual double input int    p,
int    i
const [inline, virtual]
 

Returns the value of input variable i in pattern p.

Reimplemented in PatternSet, and ArrayTrainSet.

Definition at line 57 of file patternset.h.

Referenced by copy(), filter(), join(), and ANNetwork::testPattern().

void join const PatternSource &    a,
const PatternSource &    b
 

Creates this set as union of two sets.

Definition at line 106 of file patternset.cc.

References copy(), input(), inputs, make(), output(), outputs, and patterns.

virtual void make int    patterns,
int    inputs,
int    outputs
[inline, protected, virtual]
 

Initializes a training set with given number of input and output values and patterns.

Reimplemented in PatternSet, and ArrayTrainSet.

Definition at line 162 of file patternset.h.

References inputs, outputs, and patterns.

Referenced by copy(), filter(), join(), and split().

const String& name   const [inline]
 

Returns the name of the set.

Definition at line 101 of file patternset.h.

References mName.

Referenced by setName().

void operator= const PatternSource &    other [inline]
 

Sugar for the copy operation.

Definition at line 98 of file patternset.h.

References copy().

virtual double output int    p,
int    j
const [inline, virtual]
 

Returns the value of output variable j in pattern p.

Reimplemented in PatternSet, and ArrayTrainSet.

Definition at line 60 of file patternset.h.

Referenced by copy(), filter(), getClass(), join(), Learner::test(), and Learner::testClassify().

virtual void print FILE *    out = stdout const [inline, virtual]
 

Prints the contents of the set to the given stream.

Reimplemented in PatternSet, and ArrayTrainSet.

Definition at line 54 of file patternset.h.

virtual void recombine int    startp = -1,
int    endp = -1
[inline, virtual]
 

Shuffles the patterns in the set.

Parameters:
startp  OPTIONAL Lower index of shuffling range.
endp  OPTIONAL Upper index of shuffling range.

Reimplemented in PatternSet.

Definition at line 74 of file patternset.h.

virtual void recombine2 int    startp = -1,
int    endp = -1
[inline, virtual]
 

As recombine above, except that this shuffles so that the even and odd-numbered patterns are not mixed, but preserve their evenness and oddity.

Pattern set or the shuffling range (see the parameters below) must have even number of patterns.

Parameters:
startp  OPTIONAL Lower index of shuffling range.
endp  OPTIONAL Upper index of shuffling range.

Reimplemented in PatternSet.

Definition at line 86 of file patternset.h.

void setName const String &    name [inline]
 

Sets the name of the set.

Definition at line 104 of file patternset.h.

References mName, and name().

void split PatternSource &    a,
PatternSource &    b,
double    ratio
const
 

Splits this set into two subsets a and b according to given ratio.

Definition at line 145 of file patternset.cc.

References copy(), inputs, make(), outputs, and patterns.


Member Data Documentation

int inputs
 

Number of input variables in the patterns.

Definition at line 144 of file patternset.h.

Referenced by ArrayTrainSet::ArrayTrainSet(), check(), copy(), filter(), PatternSet::getMatrix(), join(), SNNSDataFormat::load(), ArrayTrainSet::make(), make(), ArrayTrainSet::output(), PatternSet::PatternSet(), PatternSource(), PatternSet::recombine(), PatternSet::recombine2(), split(), ANNetwork::testPattern(), BackpropTrainer::trainPattern(), and ArrayTrainSet::truncate().

String mName [protected]
 

A name for the pattern set.

Definition at line 157 of file patternset.h.

Referenced by name(), PatternSource(), and setName().

int outputs
 

Number of output variables in the patterns.

Definition at line 147 of file patternset.h.

Referenced by ArrayTrainSet::ArrayTrainSet(), check(), classes(), copy(), filter(), getClass(), PatternSet::getMatrix(), join(), SNNSDataFormat::load(), ArrayTrainSet::make(), make(), PatternSet::PatternSet(), PatternSource(), AbsoluteNeuralPrediction::predict(), PatternSet::recombine(), PatternSet::recombine2(), split(), Learner::test(), Learner::testClassify(), ANNetwork::testPattern(), BackpropTrainer::trainPattern(), and ArrayTrainSet::truncate().

int patterns
 

Number of patterns in the pattern set.

Definition at line 150 of file patternset.h.

Referenced by ArrayTrainSet::ArrayTrainSet(), check(), copy(), countClasses(), filter(), PatternSet::getMatrix(), join(), SNNSDataFormat::load(), ArrayTrainSet::make(), make(), AbsoluteNeuralPrediction::makeSet(), PatternSet::PatternSet(), PatternSource(), AbsoluteNeuralPrediction::predict(), PatternSet::recombine(), PatternSet::recombine2(), split(), Learner::test(), Learner::testClassify(), Trainer::train(), BackpropTrainer::trainOnce(), and ArrayTrainSet::truncate().


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 20:06:45 2005 for Inanna by doxygen1.2.18