Classes | Public Member Functions | Public Attributes | Private Attributes
LinearSplitsTree Class Reference

#include <LinearSplitsTree.hh>

Inheritance diagram for LinearSplitsTree:
Inheritance graph
[legend]

List of all members.

Classes

struct  tree_experience
struct  tree_node

Public Member Functions

tree_nodeallocateNode ()
void buildTree (tree_node *node, const std::vector< tree_experience * > &instances, bool changed)
float calcAvgErrorforSet (const std::vector< tree_experience * > &instances)
float calcER (int dim, float val, const std::vector< tree_experience * > &instances, float error, std::vector< tree_experience * > &left, std::vector< tree_experience * > &right, float *leftError, float *rightError)
void compareSplits (float er, int dim, float val, const std::vector< tree_experience * > &left, const std::vector< tree_experience * > &right, int *nties, float leftError, float rightError, float *bestER, int *bestDim, float *bestVal, std::vector< tree_experience * > *bestLeft, std::vector< tree_experience * > *bestRight, float *bestLeftError, float *bestRightError)
void copyTree (tree_node *newNode, tree_node *origNode)
void deallocateNode (tree_node *node)
void deleteTree (tree_node *node)
float fitMultiLinearModel (const std::vector< tree_experience * > &instances, float *constant, std::vector< float > *coeff)
float fitSimpleLinearModel (const std::vector< tree_experience * > &instances, float *constant, std::vector< float > *coeff)
float getConf (const std::vector< float > &input)
virtual LinearSplitsTreegetCopy ()
tree_nodegetCorrectChild (tree_node *node, const std::vector< float > &input)
std::set< float > getUniques (int dim, const std::vector< tree_experience * > &instances, float &minVal, float &maxVal)
void implementSplit (tree_node *node, const std::vector< tree_experience * > &instances, float bestER, int bestDim, float bestVal, const std::vector< tree_experience * > &left, const std::vector< tree_experience * > &right, bool changed, float leftError, float rightError)
void initNodes ()
void initTree ()
void initTreeNode (tree_node *node)
void leafPrediction (tree_node *t, const std::vector< float > &in, std::map< float, float > *retval)
 LinearSplitsTree (int id, int trainMode, int trainFreq, int m, float featPct, bool simple, float min_er, Random rng)
 LinearSplitsTree (const LinearSplitsTree &)
void makeLeaf (tree_node *node, const std::vector< tree_experience * > &instances)
bool passTest (int dim, float val, const std::vector< float > &input)
void printTree (tree_node *t, int level)
void rebuildTree ()
float * sortOnDim (int dim, const std::vector< tree_experience * > &instances)
void testInstance (const std::vector< float > &input, std::map< float, float > *retval)
void testPossibleSplits (float avgError, const std::vector< tree_experience * > &instances, float *bestER, int *bestDim, float *bestVal, std::vector< tree_experience * > *bestLeft, std::vector< tree_experience * > *bestRight, float *bestLeftError, float *bestRightError)
bool trainInstance (classPair &instance)
bool trainInstances (std::vector< classPair > &instances)
tree_nodetraverseTree (tree_node *node, const std::vector< float > &input)
 ~LinearSplitsTree ()

Public Attributes

bool COPYDEBUG
bool DTDEBUG
bool INCDEBUG
bool LMDEBUG
int nExperiences
bool NODEDEBUG
float SPLIT_MARGIN
bool SPLITDEBUG
bool STOCH_DEBUG

Private Attributes

tree_experience allExp [N_LST_EXP]
tree_node allNodes [N_LS_NODES]
std::vector< tree_experience * > experiences
const float featPct
std::vector< int > freeNodes
const int freq
bool hadError
const int id
tree_nodelastNode
const int M
int maxnodes
const float MIN_ER
const int mode
int nnodes
int nOutput
Random rng
tree_noderoot
const bool SIMPLE
int totalnodes

Detailed Description

M5 decision tree class

Definition at line 20 of file LinearSplitsTree.hh.


Constructor & Destructor Documentation

LinearSplitsTree::LinearSplitsTree ( int  id,
int  trainMode,
int  trainFreq,
int  m,
float  featPct,
bool  simple,
float  min_er,
Random  rng 
)

Definition at line 18 of file LinearSplitsTree.cc.

Definition at line 59 of file LinearSplitsTree.cc.

Definition at line 149 of file LinearSplitsTree.cc.


Member Function Documentation

Definition at line 1512 of file LinearSplitsTree.cc.

void LinearSplitsTree::buildTree ( tree_node node,
const std::vector< tree_experience * > &  instances,
bool  changed 
)

Build the tree from this node down using this set of experiences.

Definition at line 603 of file LinearSplitsTree.cc.

float LinearSplitsTree::calcAvgErrorforSet ( const std::vector< tree_experience * > &  instances)

Calculate std deviation for set.

Definition at line 1327 of file LinearSplitsTree.cc.

float LinearSplitsTree::calcER ( int  dim,
float  val,
const std::vector< tree_experience * > &  instances,
float  avgError,
std::vector< tree_experience * > &  left,
std::vector< tree_experience * > &  right,
float *  leftError,
float *  rightError 
)

Calculate error reduction for this possible split.

Definition at line 1274 of file LinearSplitsTree.cc.

void LinearSplitsTree::compareSplits ( float  er,
int  dim,
float  val,
const std::vector< tree_experience * > &  left,
const std::vector< tree_experience * > &  right,
int *  nties,
float  leftError,
float  rightError,
float *  bestER,
int *  bestDim,
float *  bestVal,
std::vector< tree_experience * > *  bestLeft,
std::vector< tree_experience * > *  bestRight,
float *  bestLeftError,
float *  bestRightError 
)

Decide if this split is better.

Definition at line 1216 of file LinearSplitsTree.cc.

void LinearSplitsTree::copyTree ( tree_node newNode,
tree_node origNode 
)

Definition at line 113 of file LinearSplitsTree.cc.

Definition at line 1531 of file LinearSplitsTree.cc.

delete current tree

Definition at line 524 of file LinearSplitsTree.cc.

float LinearSplitsTree::fitMultiLinearModel ( const std::vector< tree_experience * > &  instances,
float *  constant,
std::vector< float > *  coeff 
)

Definition at line 708 of file LinearSplitsTree.cc.

float LinearSplitsTree::fitSimpleLinearModel ( const std::vector< tree_experience * > &  instances,
float *  constant,
std::vector< float > *  coeff 
)

Definition at line 940 of file LinearSplitsTree.cc.

float LinearSplitsTree::getConf ( const std::vector< float > &  input) [virtual]

Implements Classifier.

Definition at line 444 of file LinearSplitsTree.cc.

Implements Classifier.

Definition at line 144 of file LinearSplitsTree.cc.

LinearSplitsTree::tree_node * LinearSplitsTree::getCorrectChild ( tree_node node,
const std::vector< float > &  input 
)

Get the correct child of this node based on the input

Definition at line 562 of file LinearSplitsTree.cc.

std::set< float > LinearSplitsTree::getUniques ( int  dim,
const std::vector< tree_experience * > &  instances,
float &  minVal,
float &  maxVal 
)

Returns the unique elements at this index

Definition at line 1350 of file LinearSplitsTree.cc.

void LinearSplitsTree::implementSplit ( tree_node node,
const std::vector< tree_experience * > &  instances,
float  bestER,
int  bestDim,
float  bestVal,
const std::vector< tree_experience * > &  left,
const std::vector< tree_experience * > &  right,
bool  changed,
float  leftError,
float  rightError 
)

Definition at line 1061 of file LinearSplitsTree.cc.

Definition at line 1500 of file LinearSplitsTree.cc.

Definition at line 473 of file LinearSplitsTree.cc.

Definition at line 489 of file LinearSplitsTree.cc.

void LinearSplitsTree::leafPrediction ( tree_node t,
const std::vector< float > &  in,
std::map< float, float > *  retval 
)

Definition at line 1476 of file LinearSplitsTree.cc.

void LinearSplitsTree::makeLeaf ( tree_node node,
const std::vector< tree_experience * > &  instances 
)

Definition at line 677 of file LinearSplitsTree.cc.

bool LinearSplitsTree::passTest ( int  dim,
float  val,
const std::vector< float > &  input 
)

Decide if this passes the test

Definition at line 589 of file LinearSplitsTree.cc.

void LinearSplitsTree::printTree ( tree_node t,
int  level 
)

Print the tree for debug purposes.

Definition at line 1439 of file LinearSplitsTree.cc.

Definition at line 411 of file LinearSplitsTree.cc.

float * LinearSplitsTree::sortOnDim ( int  dim,
const std::vector< tree_experience * > &  instances 
)

Returns a list of the attributes in this dimension sorted from lowest to highest.

Definition at line 1383 of file LinearSplitsTree.cc.

void LinearSplitsTree::testInstance ( const std::vector< float > &  input,
std::map< float, float > *  retval 
) [virtual]

Implements Classifier.

Definition at line 424 of file LinearSplitsTree.cc.

void LinearSplitsTree::testPossibleSplits ( float  avgError,
const std::vector< tree_experience * > &  instances,
float *  bestER,
int *  bestDim,
float *  bestVal,
std::vector< tree_experience * > *  bestLeft,
std::vector< tree_experience * > *  bestRight,
float *  bestLeftError,
float *  bestRightError 
)

Definition at line 1161 of file LinearSplitsTree.cc.

bool LinearSplitsTree::trainInstance ( classPair instance) [virtual]

Implements Classifier.

Definition at line 158 of file LinearSplitsTree.cc.

bool LinearSplitsTree::trainInstances ( std::vector< classPair > &  instances) [virtual]

Implements Classifier.

Definition at line 280 of file LinearSplitsTree.cc.

LinearSplitsTree::tree_node * LinearSplitsTree::traverseTree ( tree_node node,
const std::vector< float > &  input 
)

Traverse the tree to the leaf for this input.

Definition at line 575 of file LinearSplitsTree.cc.


Member Data Documentation

Definition at line 160 of file LinearSplitsTree.hh.

Definition at line 161 of file LinearSplitsTree.hh.

Definition at line 135 of file LinearSplitsTree.hh.

Definition at line 129 of file LinearSplitsTree.hh.

Definition at line 159 of file LinearSplitsTree.hh.

const float LinearSplitsTree::featPct [private]

Definition at line 146 of file LinearSplitsTree.hh.

std::vector<int> LinearSplitsTree::freeNodes [private]

Definition at line 162 of file LinearSplitsTree.hh.

const int LinearSplitsTree::freq [private]

Definition at line 144 of file LinearSplitsTree.hh.

Definition at line 154 of file LinearSplitsTree.hh.

const int LinearSplitsTree::id [private]

Definition at line 141 of file LinearSplitsTree.hh.

Definition at line 128 of file LinearSplitsTree.hh.

Definition at line 166 of file LinearSplitsTree.hh.

Definition at line 130 of file LinearSplitsTree.hh.

const int LinearSplitsTree::M [private]

Definition at line 145 of file LinearSplitsTree.hh.

Definition at line 156 of file LinearSplitsTree.hh.

const float LinearSplitsTree::MIN_ER [private]

Definition at line 148 of file LinearSplitsTree.hh.

const int LinearSplitsTree::mode [private]

Definition at line 143 of file LinearSplitsTree.hh.

Definition at line 134 of file LinearSplitsTree.hh.

int LinearSplitsTree::nnodes [private]

Definition at line 153 of file LinearSplitsTree.hh.

Definition at line 133 of file LinearSplitsTree.hh.

Definition at line 152 of file LinearSplitsTree.hh.

Definition at line 150 of file LinearSplitsTree.hh.

Definition at line 165 of file LinearSplitsTree.hh.

const bool LinearSplitsTree::SIMPLE [private]

Definition at line 147 of file LinearSplitsTree.hh.

Definition at line 137 of file LinearSplitsTree.hh.

Definition at line 131 of file LinearSplitsTree.hh.

Definition at line 132 of file LinearSplitsTree.hh.

Definition at line 155 of file LinearSplitsTree.hh.


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


rl_agent
Author(s): Todd Hester
autogenerated on Thu Jun 6 2019 22:00:14