Darwin
1.10(beta)
|
Implements a multi-class logistic classifier templated on a drwnJointFeatureMap. More...
Public Member Functions | |
drwnTMultiClassLogistic () | |
default constructor | |
drwnTMultiClassLogistic (unsigned n, unsigned k=2) | |
construct a k-class logistic classifier for data of dimension n | |
drwnTMultiClassLogistic (const drwnTMultiClassLogistic< FeatureMap > &c) | |
copy constructor | |
virtual drwnTMultiClassLogistic < FeatureMap > * | clone () const |
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } | |
virtual void | initialize (unsigned n, unsigned k=2) |
initialize the classifier object for n features and k classes | |
virtual void | getClassScores (const vector< double > &features, vector< double > &outputScores) const |
compute the unnormalized log-probability for a single feature vector More... | |
![]() | |
drwnMultiClassLogisticBase () | |
default constructor | |
drwnMultiClassLogisticBase (unsigned n, unsigned k=2) | |
construct a k-class logistic classifier for data of dimension n | |
drwnMultiClassLogisticBase (const drwnMultiClassLogisticBase &c) | |
copy constructor | |
virtual const char * | type () const |
returns object type as a string (e.g., Foo::type() { return "Foo"; }) | |
virtual bool | save (drwnXMLNode &xml) const |
write object to XML node (see also write) | |
virtual bool | load (drwnXMLNode &xml) |
read object from XML node (see also read) | |
virtual double | train (const drwnClassifierDataset &dataset) |
train the parameters of the classifier from a drwnClassifierDataset object | |
virtual double | train (const vector< vector< double > > &features, const vector< int > &targets) |
train the parameters of the classifier from a set of features and corresponding labels | |
virtual double | train (const vector< vector< double > > &features, const vector< int > &targets, const vector< double > &weights) |
train the parameters of the classifier from a weighted set of features and corresponding labels | |
![]() | |
drwnClassifier () | |
default constructor | |
drwnClassifier (unsigned n, unsigned k=2) | |
construct a classifer with n features and k classes | |
drwnClassifier (const drwnClassifier &c) | |
copy constructor | |
int | numFeatures () const |
returns the number of features expected by the classifier object | |
int | numClasses () const |
returns the number of classes predicted by the classifier object | |
virtual bool | valid () const |
returns true if the classifier is valid (has been initialized and trained) | |
virtual double | train (const char *filename) |
train the parameters of the classifier from data stored in filename | |
virtual void | getClassScores (const vector< vector< double > > &features, vector< vector< double > > &outputScores) const |
compute the unnormalized log-probability for a set of feature vectors | |
virtual void | getClassMarginals (const vector< double > &features, vector< double > &outputMarginals) const |
compute the class marginal probabilities for a single feature vector | |
virtual void | getClassMarginals (const vector< vector< double > > &features, vector< vector< double > > &outputMarginals) const |
compute the class marginal probabilities for a set of feature vectors | |
virtual int | getClassification (const vector< double > &features) const |
return the most likely class label for a single feature vector | |
virtual void | getClassifications (const vector< vector< double > > &features, vector< int > &outputLabels) const |
compute the most likely class labels for a set of feature vector | |
![]() | |
bool | write (const char *filename) const |
write object to file (calls save) | |
bool | read (const char *filename) |
read object from file (calls load) | |
void | dump () const |
print object's current state to standard output (for debugging) | |
![]() | |
unsigned | numProperties () const |
bool | hasProperty (const string &name) const |
bool | hasProperty (const char *name) const |
unsigned | findProperty (const string &name) const |
unsigned | findProperty (const char *name) const |
void | setProperty (unsigned indx, bool value) |
void | setProperty (unsigned indx, int value) |
void | setProperty (unsigned indx, double value) |
void | setProperty (unsigned indx, const string &value) |
void | setProperty (unsigned indx, const char *value) |
void | setProperty (unsigned indx, const Eigen::VectorXd &value) |
void | setProperty (unsigned indx, const Eigen::MatrixXd &value) |
void | setProperty (const char *name, bool value) |
void | setProperty (const char *name, int value) |
void | setProperty (const char *name, double value) |
void | setProperty (const char *name, const string &value) |
void | setProperty (const char *name, const char *value) |
void | setProperty (const char *name, const Eigen::VectorXd &value) |
void | setProperty (const char *name, const Eigen::MatrixXd &value) |
string | getPropertyAsString (unsigned indx) const |
drwnPropertyType | getPropertyType (unsigned indx) const |
bool | isReadOnly (unsigned indx) const |
const drwnPropertyInterface * | getProperty (unsigned indx) const |
const drwnPropertyInterface * | getProperty (const char *name) const |
bool | getBoolProperty (unsigned indx) const |
int | getIntProperty (unsigned indx) const |
double | getDoubleProperty (unsigned indx) const |
const string & | getStringProperty (unsigned indx) const |
const list< string > & | getListProperty (unsigned indx) const |
int | getSelectionProperty (unsigned indx) const |
const Eigen::VectorXd & | getVectorProperty (unsigned indx) const |
const Eigen::MatrixXd & | getMatrixProperty (unsigned indx) const |
const string & | getPropertyName (unsigned indx) const |
vector< string > | getPropertyNames () const |
void | readProperties (drwnXMLNode &xml, const char *tag="property") |
void | writeProperties (drwnXMLNode &xml, const char *tag="property") const |
void | printProperties (ostream &os) const |
Protected Member Functions | |
virtual double | objectiveAndGradient (const double *x, double *df) const |
returns value of objective function and populates gradient df at point x | |
![]() | |
double | objective (const double *x) const |
returns value of objective function at point x | |
void | gradient (const double *x, double *df) const |
populates gradient of objective function at point x | |
![]() | |
void | declareProperty (const string &name, drwnPropertyInterface *optif) |
void | undeclareProperty (const string &name) |
void | exposeProperties (drwnProperties *opts, const string &prefix=string(""), bool bSerializable=false) |
virtual void | propertyChanged (const string &name) |
![]() | |
drwnOptimizer () | |
default constructor | |
drwnOptimizer (unsigned n) | |
construct a problem with dimension n | |
drwnOptimizer (const drwnOptimizer &o) | |
copy constructor | |
void | initialize (unsigned n, const double *x=NULL) |
initialize an optimization problem of size n possibly with feasible starting point x ![]() | |
void | initialize (const double *x=NULL) |
initialize an optimization problem at feasible starting point x in ![]() | |
double | solve (unsigned maxiter, bool bMonitor=false) |
Solve the optimization problem for up to maxiter iterations to precision set by EPSF, EPSG, and EPSX static variables. Calls monitor function after each iteration if bMonitor is true. | |
unsigned | size () const |
dimension of optimization problem | |
double | operator[] (unsigned i) const |
returns the i-th component of the current solution | |
double & | operator[] (unsigned i) |
returns a reference to the i-th component of the current solution | |
virtual void | monitor (unsigned iter, double objValue) |
callback for each iteration during optimization (if bMonitor is true) | |
Additional Inherited Members | |
![]() | |
static double | REG_STRENGTH = 1.0e-9 |
default strength of regularizer (used during construction) | |
static int | MAX_ITERATIONS = 1000 |
maximum number of training iterations | |
![]() | |
VectorXd | _theta |
joint feature map weights | |
int | _regularizer |
regularization option | |
double | _lambda |
regularization strength | |
const vector< vector< double > > * | _features |
const vector< int > * | _targets |
const vector< double > * | _weights |
![]() | |
int | _nFeatures |
number of features | |
int | _nClasses |
number of classes | |
bool | _bValid |
true if the classifier has been trained or loaded | |
![]() | |
unsigned | _n |
dimension of optimization problem (i.e., ![]() | |
double * | _x |
current feasible solution in ![]() | |
double * | _df |
gradient at _x in ![]() | |
![]() | |
static double | EPSF = 1.0e-6 |
default tolerance on function convergence | |
static double | EPSG = 1.0e-3 |
deafult tolerance on gradient convergence | |
static double | EPSX = 1.0e-6 |
default tolerance on solution convergence | |
Implements a multi-class logistic classifier templated on a drwnJointFeatureMap.
Parameters are learned using the negative log-likelihood loss and can be regularized with L2 or huber penalty.
|
virtual |
compute the unnormalized log-probability for a single feature vector
Implements drwnMultiClassLogisticBase.