HOG2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
LinearRegression Class Reference

#include <LinearRegression.h>

Inheritance diagram for LinearRegression:
Inheritance graph
[legend]
Collaboration diagram for LinearRegression:
Collaboration graph
[legend]

Public Member Functions

 LinearRegression (int _inputs, int _outputs, double learnrate)
 
 LinearRegression (LinearRegression *)
 
 LinearRegression (char *)
 
 LinearRegression (FunctionApproximator *)
 
 ~LinearRegression ()
 
void setUseBinary (bool binary)
 
void resizeInputs (int newSize, double newVal)
 
void resizeInputs (int newSize)
 
void save (const char *)
 
void save (FILE *)
 
void load (const char *)
 
void load (FILE *)
 
void load (const FunctionApproximator *fa)
 
void load (const LinearRegression *)
 
double train (std::vector< double > &input, std::vector< double > &output2)
 
double * test (const std::vector< double > &input)
 
double train (std::vector< unsigned int > &input, std::vector< double > &output2)
 
double * test (const std::vector< unsigned int > &input)
 
void Print ()
 
int getNumInputs ()
 
void setInputWeight (double value, unsigned int weightNum, unsigned int whichOutput=0)
 
double getInputWeight (int inp, int outp=0)
 
void getWeightUpdateVariance (std::vector< double > &var, unsigned int which=0)
 
double getWeightUpdateVariance (unsigned int weightNum, unsigned int whichOutput=0)
 
void getWeightUpdateAverage (std::vector< double > &var, unsigned int which=0)
 
double getWeightUpdateAverage (unsigned int weightNum, unsigned int whichOutput=0)
 
void getWeightUpdateSum (std::vector< double > &var, unsigned int which=0)
 
double getWeightUpdateSum (unsigned int weightNum, unsigned int whichOutput=0)
 
void resetWeightVariance (unsigned int weightNum, unsigned int whichOutput=0)
 
void resetWeightVariance ()
 
int getWeightFrequency (unsigned int weightNum, unsigned int whichOutput=0)
 
double GetInput (std::vector< double > &input, const std::vector< double > &target)
 
- Public Member Functions inherited from FunctionApproximator
 FunctionApproximator ()
 
virtual ~FunctionApproximator ()
 
virtual void setLearnRate (double)
 
virtual double getLearnRate ()
 
void setOutputActivation (tActivation t)
 
tActivation getOutputActivation ()
 

Static Public Member Functions

static bool validSaveFile (char *fname)
 

Private Member Functions

void allocateMemory ()
 
void freeMemory ()
 
double g (double a)
 
double dg (double a)
 
double outputerr (std::vector< double > &output, std::vector< double > &expected, int which)
 
double error (double *output)
 

Private Attributes

std::vector< std::vector< double > > weight
 
std::vector< std::vector< updateData > > updates
 
std::vector< double > output
 
int inputs
 
int outputs
 
bool useBinary
 

Additional Inherited Members

- Protected Attributes inherited from FunctionApproximator
double rate
 
tActivation outputActivation
 

Detailed Description

Definition at line 27 of file LinearRegression.h.

Constructor & Destructor Documentation

◆ LinearRegression() [1/4]

LinearRegression::LinearRegression ( int  _inputs,
int  _outputs,
double  learnrate 
)

◆ LinearRegression() [2/4]

LinearRegression::LinearRegression ( LinearRegression perp)

◆ LinearRegression() [3/4]

LinearRegression::LinearRegression ( char *  f)

Definition at line 50 of file LinearRegression.cpp.

References inputs, load(), outputs, updates, useBinary, and weight.

◆ LinearRegression() [4/4]

LinearRegression::LinearRegression ( FunctionApproximator fa)

◆ ~LinearRegression()

LinearRegression::~LinearRegression ( )

Definition at line 75 of file LinearRegression.cpp.

References freeMemory().

Member Function Documentation

◆ allocateMemory()

void LinearRegression::allocateMemory ( )
private

Definition at line 138 of file LinearRegression.cpp.

References inputs, output, outputs, updates, and weight.

Referenced by LinearRegression(), and load().

◆ dg()

double LinearRegression::dg ( double  a)
private

◆ error()

double LinearRegression::error ( double *  output)
private

◆ freeMemory()

void LinearRegression::freeMemory ( )
private

Definition at line 154 of file LinearRegression.cpp.

References updates, and weight.

Referenced by load(), and ~LinearRegression().

◆ g()

double LinearRegression::g ( double  a)
private

◆ GetInput()

double LinearRegression::GetInput ( std::vector< double > &  input,
const std::vector< double > &  target 
)
inlinevirtual

Implements FunctionApproximator.

Definition at line 71 of file LinearRegression.h.

◆ getInputWeight()

double LinearRegression::getInputWeight ( int  inp,
int  outp = 0 
)
inlinevirtual

Reimplemented from FunctionApproximator.

Definition at line 57 of file LinearRegression.h.

References weight.

◆ getNumInputs()

int LinearRegression::getNumInputs ( )
inlinevirtual

Reimplemented from FunctionApproximator.

Definition at line 55 of file LinearRegression.h.

References inputs.

◆ getWeightFrequency()

int LinearRegression::getWeightFrequency ( unsigned int  weightNum,
unsigned int  whichOutput = 0 
)

Definition at line 496 of file LinearRegression.cpp.

References updates.

◆ getWeightUpdateAverage() [1/2]

void LinearRegression::getWeightUpdateAverage ( std::vector< double > &  var,
unsigned int  which = 0 
)

Definition at line 437 of file LinearRegression.cpp.

References updateData::n, updateData::totErr, updates, and weight.

◆ getWeightUpdateAverage() [2/2]

double LinearRegression::getWeightUpdateAverage ( unsigned int  weightNum,
unsigned int  whichOutput = 0 
)

Definition at line 451 of file LinearRegression.cpp.

References updateData::n, updateData::totErr, updates, and weight.

◆ getWeightUpdateSum() [1/2]

void LinearRegression::getWeightUpdateSum ( std::vector< double > &  var,
unsigned int  which = 0 
)

Definition at line 462 of file LinearRegression.cpp.

References updates, and weight.

◆ getWeightUpdateSum() [2/2]

double LinearRegression::getWeightUpdateSum ( unsigned int  weightNum,
unsigned int  whichOutput = 0 
)

Definition at line 472 of file LinearRegression.cpp.

References updates, and weight.

◆ getWeightUpdateVariance() [1/2]

void LinearRegression::getWeightUpdateVariance ( std::vector< double > &  var,
unsigned int  which = 0 
)

Definition at line 412 of file LinearRegression.cpp.

References updateData::n, updateData::S, updates, and weight.

◆ getWeightUpdateVariance() [2/2]

double LinearRegression::getWeightUpdateVariance ( unsigned int  weightNum,
unsigned int  whichOutput = 0 
)

Definition at line 426 of file LinearRegression.cpp.

References updateData::n, updateData::S, updates, and weight.

◆ load() [1/4]

void LinearRegression::load ( const char *  fname)
virtual

Implements FunctionApproximator.

Definition at line 168 of file LinearRegression.cpp.

Referenced by LinearRegression().

◆ load() [2/4]

void LinearRegression::load ( const FunctionApproximator fa)
inlinevirtual

Implements FunctionApproximator.

Definition at line 44 of file LinearRegression.h.

References load().

Referenced by load().

◆ load() [3/4]

void LinearRegression::load ( const LinearRegression p)

◆ load() [4/4]

void LinearRegression::load ( FILE *  f)
virtual

◆ outputerr()

double LinearRegression::outputerr ( std::vector< double > &  output,
std::vector< double > &  expected,
int  which 
)
private

Definition at line 328 of file LinearRegression.cpp.

Referenced by train().

◆ Print()

void LinearRegression::Print ( )
virtual

Implements FunctionApproximator.

Definition at line 507 of file LinearRegression.cpp.

References inputs, outputs, and weight.

◆ resetWeightVariance() [1/2]

void LinearRegression::resetWeightVariance ( )

Definition at line 485 of file LinearRegression.cpp.

References updates.

◆ resetWeightVariance() [2/2]

void LinearRegression::resetWeightVariance ( unsigned int  weightNum,
unsigned int  whichOutput = 0 
)

Definition at line 480 of file LinearRegression.cpp.

References updates.

◆ resizeInputs() [1/2]

void LinearRegression::resizeInputs ( int  newSize)

Definition at line 109 of file LinearRegression.cpp.

References inputs, outputs, updates, and weight.

◆ resizeInputs() [2/2]

void LinearRegression::resizeInputs ( int  newSize,
double  newVal 
)

Definition at line 80 of file LinearRegression.cpp.

References inputs, outputs, updates, and weight.

◆ save() [1/2]

void LinearRegression::save ( const char *  fname)
virtual

Implements FunctionApproximator.

Definition at line 288 of file LinearRegression.cpp.

◆ save() [2/2]

void LinearRegression::save ( FILE *  f)
virtual

Implements FunctionApproximator.

Definition at line 301 of file LinearRegression.cpp.

References inputs, little2machine(), outputs, useBinary, VERSION, and weight.

◆ setInputWeight()

void LinearRegression::setInputWeight ( double  value,
unsigned int  weightNum,
unsigned int  whichOutput = 0 
)

Definition at line 501 of file LinearRegression.cpp.

References updates, and weight.

◆ setUseBinary()

void LinearRegression::setUseBinary ( bool  binary)
inline

Definition at line 35 of file LinearRegression.h.

References useBinary.

◆ test() [1/2]

double * LinearRegression::test ( const std::vector< double > &  input)
virtual

Implements FunctionApproximator.

Definition at line 399 of file LinearRegression.cpp.

References inputs, output, outputs, and weight.

Referenced by train().

◆ test() [2/2]

double * LinearRegression::test ( const std::vector< unsigned int > &  input)
virtual

Implements FunctionApproximator.

Definition at line 386 of file LinearRegression.cpp.

References inputs, output, outputs, and weight.

◆ train() [1/2]

double LinearRegression::train ( std::vector< double > &  input,
std::vector< double > &  output2 
)
virtual

◆ train() [2/2]

double LinearRegression::train ( std::vector< unsigned int > &  input,
std::vector< double > &  output2 
)
virtual

◆ validSaveFile()

bool LinearRegression::validSaveFile ( char *  fname)
static

Definition at line 265 of file LinearRegression.cpp.

References VERSION.

Member Data Documentation

◆ inputs

int LinearRegression::inputs
private

◆ output

std::vector<double> LinearRegression::output
private

Definition at line 86 of file LinearRegression.h.

Referenced by allocateMemory(), test(), and train().

◆ outputs

int LinearRegression::outputs
private

◆ updates

std::vector<std::vector<updateData> > LinearRegression::updates
private

◆ useBinary

bool LinearRegression::useBinary
private

Definition at line 90 of file LinearRegression.h.

Referenced by LinearRegression(), load(), save(), and setUseBinary().

◆ weight

std::vector<std::vector<double> > LinearRegression::weight
private

The documentation for this class was generated from the following files: