Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnRegression.h
1 /******************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnRegression.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 
15 #include <cstdlib>
16 #include <vector>
17 
18 #include "drwnBase.h"
19 #include "drwnDataset.h"
20 
21 using namespace std;
22 
23 // drwnRegression -----------------------------------------------------------
26 
28  protected:
29  int _nFeatures;
30  bool _bValid;
31 
32  public:
36  drwnRegression(unsigned n);
39  virtual ~drwnRegression() {
40  // do nothing
41  }
42 
43  // access functions
45  int numFeatures() const { return _nFeatures; }
47  virtual bool valid() const { return _bValid; }
48 
49  // initialization
51  virtual void initialize(unsigned n);
52 
53  // i/o
54  virtual bool save(drwnXMLNode& xml) const;
55  virtual bool load(drwnXMLNode& xml);
56 
57  // training
59  virtual double train(const drwnRegressionDataset& dataset) = 0;
61  virtual double train(const vector<vector<double> >& features,
62  const vector<double>& targets);
64  virtual double train(const vector<vector<double> >& features,
65  const vector<double>& targets, const vector<double>& weights);
67  virtual double train(const char *filename);
68 
69  // evaluation (regression)
71  virtual double getRegression(const vector<double>& features) const = 0;
74  virtual void getRegressions(const vector<vector<double> >& features,
75  vector<double>& outputTargets) const;
76 };
Provides an abstract interface for dynamic properties.
Definition: drwnProperties.h:338
Implements the interface for a generic machine learning regression, e.g. see drwnLinearRegressor.
Definition: drwnRegression.h:27
virtual bool valid() const
return true if the regressor has valid parameters (i.e., has been trained)
Definition: drwnRegression.h:47
int _nFeatures
number of features
Definition: drwnRegression.h:29
int numFeatures() const
return the dimensionality of the feature space
Definition: drwnRegression.h:45
bool _bValid
true if regression parameters are trained or loaded
Definition: drwnRegression.h:30
Implements a cacheable dataset containing feature vectors, labels and optional weights.
Definition: drwnDataset.h:43
standard Darwin object interface (cloneable and writeable)
Definition: drwnInterfaces.h:72