Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnCrossValidator.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: drwnCrossValidator.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 #include <map>
18 
19 #include "drwnBase.h"
20 #include "drwnIO.h"
21 #include "drwnDataset.h"
22 #include "drwnClassifier.h"
23 
24 using namespace std;
25 
26 // drwnCrossValidator -------------------------------------------------------
29 
31  protected:
32  map<string, list<string> > _settings; //<! property/value list
33 
34  public:
35  drwnCrossValidator() { /* do nothing */ }
36  virtual ~drwnCrossValidator() { /* do nothing */ }
37 
38  // i/o
39  const char *type() const { return "drwnCrossValidator"; }
40  bool save(drwnXMLNode& xml) const;
41  bool load(drwnXMLNode& xml);
42 
44  unsigned trials() const;
45 
47  void clear() { _settings.clear(); }
49  void clear(const char *property);
50 
52  void add(const char *property, const char *value);
54  void addLinear(const char *property, double startValue, double endValue, int numSteps = 10);
56  void addLogarithmic(const char *property, double startValue, double endValue, int numSteps = 10);
57 
59  double crossValidate(drwnClassifier * &classifier,
60  const drwnClassifierDataset& trainSet,
61  const drwnClassifierDataset& testSet) const;
62 
63  protected:
65  virtual double score(drwnClassifier const *classifier,
66  const drwnClassifierDataset& testSet) const;
67 };
void clear()
clear all settings
Definition: drwnCrossValidator.h:47
interface for objects that can serialize and de-serialize themselves
Definition: drwnInterfaces.h:48
Utility class for cross-validating classifier meta-parameters by brute-force testing of all combinati...
Definition: drwnCrossValidator.h:30
Implements the interface for a generic machine learning classifier.
Definition: drwnClassifier.h:31
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnCrossValidator.h:39
Implements a cacheable dataset containing feature vectors, labels and optional weights.
Definition: drwnDataset.h:43