SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Machine.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #include <shogun/machine/Machine.h>
12 #include <shogun/base/Parameter.h>
14 
15 using namespace shogun;
16 
17 CMachine::CMachine() : CSGObject(), max_train_time(0), labels(NULL),
18  solver_type(ST_AUTO)
19 {
20  m_parameters->add(&max_train_time, "max_train_time",
21  "Maximum training time.");
22  m_parameters->add((machine_int_t*) &solver_type, "solver_type");
23  m_parameters->add((CSGObject**) &labels, "labels");
24  m_parameters->add(&m_store_model_features, "store_model_features",
25  "Should feature data of model be stored after training?");
26 
28 }
29 
31 {
33 }
34 
36 {
37  bool result = train_machine(data);
38 
41 
42  return result;
43 }
44 
46 {
48  return CMath::INFTY;
49 }
50 
51 bool CMachine::load(FILE* srcfile)
52 {
53  ASSERT(srcfile);
54  return false;
55 }
56 
57 bool CMachine::save(FILE* dstfile)
58 {
59  ASSERT(dstfile);
60  return false;
61 }
62 
64 {
66  SG_REF(lab);
67  labels = lab;
68 }
69 
71 {
72  SG_REF(labels);
73  return labels;
74 }
75 
77 {
78  if (!labels)
79  SG_ERROR("No Labels assigned\n");
80 
81  return labels->get_label(i);
82 }
83 
85 {
86  max_train_time = t;
87 }
88 
90 {
91  return max_train_time;
92 }
93 
95 {
96  return CT_NONE;
97 }
98 
100 {
101  solver_type = st;
102 }
103 
105 {
106  return solver_type;
107 }
108 
110 {
111  m_store_model_features = store_model;
112 }
113 
114 
void set_max_train_time(float64_t t)
Definition: Machine.cpp:84
virtual CLabels * apply()=0
virtual bool load(FILE *srcfile)
Definition: Machine.cpp:51
virtual float64_t get_label(int32_t i)
Definition: Machine.cpp:76
EClassifierType
Definition: Machine.h:27
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:35
static const float64_t INFTY
infinity
Definition: Math.h:1594
ESolverType
Definition: Machine.h:74
#define SG_ERROR(...)
Definition: SGIO.h:75
#define SG_NOTIMPLEMENTED
Definition: SGIO.h:82
Parameter * m_parameters
Definition: SGObject.h:297
virtual bool train_machine(CFeatures *data=NULL)
Definition: Machine.h:223
bool m_store_model_features
Definition: Machine.h:257
#define SG_REF(x)
Definition: SGObject.h:44
CLabels * labels
Definition: Machine.h:251
void add(bool *param, const char *name, const char *description="")
Definition: Parameter.cpp:23
virtual void set_store_model_features(bool store_model)
Definition: Machine.cpp:109
#define ASSERT(x)
Definition: SGIO.h:102
virtual ~CMachine()
Definition: Machine.cpp:30
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:76
virtual bool save(FILE *dstfile)
Definition: Machine.cpp:57
double float64_t
Definition: common.h:56
float64_t get_label(int32_t idx)
Definition: Labels.cpp:223
float64_t max_train_time
Definition: Machine.h:248
virtual EClassifierType get_classifier_type()
Definition: Machine.cpp:94
virtual CLabels * get_labels()
Definition: Machine.cpp:70
float64_t get_max_train_time()
Definition: Machine.cpp:89
ESolverType get_solver_type()
Definition: Machine.cpp:104
virtual void store_model_features()
Definition: Machine.h:240
#define SG_UNREF(x)
Definition: SGObject.h:45
int machine_int_t
Definition: common.h:65
The class Features is the base class of all feature objects.
Definition: Features.h:56
virtual bool train(CFeatures *data=NULL)
Definition: Machine.cpp:35
ESolverType solver_type
Definition: Machine.h:254
virtual void set_labels(CLabels *lab)
Definition: Machine.cpp:63
void set_solver_type(ESolverType st)
Definition: Machine.cpp:99

SHOGUN Machine Learning Toolbox - Documentation