STK++ 0.9.13
STK_IRunner.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANYArray_; without even the implied warranty of
11 MERCHANTABILIYArray_ or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23 */
24
25/*
26 * Project: stkpp::Sdk
27 * created on: 29 juil. 2011
28 * Purpose: main interface base class for running method.
29 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
30 **/
31
37#ifndef STK_IRUNNER_H
38#define STK_IRUNNER_H
39
41namespace STK
42{
65{
66 protected:
76 inline virtual ~IRunnerBase() {}
77
78 public:
82 inline String const& error() const { return msg_error_;}
87 virtual bool run() =0;
88
89 protected:
94 inline virtual void update() {}
98 bool hasRun_;
99};
100
120template < class Array>
122{
123 protected:
125 inline IRunnerWithData() : p_data_(0) {}
129 inline IRunnerWithData( Array const* const p_data) : p_data_(p_data) {}
133 inline IRunnerWithData( Array const& data) : p_data_(&data) {}
143
144 public:
148 inline Array const* p_data() const { return p_data_;}
153 inline virtual void setData( Array const* p_data)
154 {
155 p_data_ = p_data;
156 update();
157 this->hasRun_ = false;
158 }
163 inline virtual void setData( Array const& data)
164 {
165 p_data_ = &data;
166 update();
167 this->hasRun_ = false;
168 }
169
170 protected:
172 Array const* p_data_;
173};
174
188template < class Array, class Weights_>
190{
191 protected:
197 inline IRunnerUnsupervised( Array const* const p_data) : p_data_(p_data) {}
201 inline IRunnerUnsupervised( Array const& data) : p_data_(&data) {}
211
212 public:
216 inline Array const* p_data() const { return p_data_;}
221 inline virtual void setData( Array const* p_data)
222 {
223 p_data_ = p_data;
224 update();
225 }
230 inline virtual void setData( Array const& data)
231 {
232 p_data_ = &data;
233 update();
234 this->hasRun_ = false;
235 }
240 virtual bool run() =0;
246 virtual bool run( Weights_ const& weights) =0;
247
248 protected:
250 Array const* p_data_;
251};
252
268template < typename YArray_, typename XArray_, class Weights_>
270{
271 protected:
277 IRunnerSupervised( YArray_ const* const& p_y, XArray_ const* const& p_x)
278 : p_y_(p_y), p_x_(p_x)
279 {}
284 : p_y_(&y), p_x_(&x)
285 {}
295
296 public:
302 virtual void setX( XArray_ const& x)
303 {
304 p_x_ = &x;
305 updateX();
306 this->hasRun_ = false;
307 }
308
313 virtual void setY( YArray_ const& y)
314 {
315 p_y_ = &y;
316 updateY();
317 this->hasRun_ = false;
318 }
324 virtual void setData( YArray_ const& y, XArray_ const& x)
325 {
326 p_y_ = &y;
327 p_x_ = &x;
328 update();
329 this->hasRun_ = false;
330 }
335 virtual bool run() =0;
341 virtual bool run( Weights_ const& weights) =0;
342
343 protected:
345 YArray_ const* p_y_;
347 XArray_ const* p_x_;
352 virtual void updateY() {}
357 virtual void updateX() {}
362 virtual void update() { updateX(); updateY();}
363};
364
365} // namespace STK
366
367#endif /* STK_IRUNNER_H */
In this file we define the fundamental type String.
Abstract base class for all classes having a.
Definition STK_IRunner.h:65
virtual ~IRunnerBase()
destructor
Definition STK_IRunner.h:76
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
virtual void update()
update the runner.
Definition STK_IRunner.h:94
IRunnerBase()
default constructor
Definition STK_IRunner.h:68
IRunnerBase(IRunnerBase const &runner)
copy constructor
Definition STK_IRunner.h:72
virtual bool run()=0
run the computations.
bool hasRun_
true if run has been used, false otherwise
Definition STK_IRunner.h:98
String const & error() const
get the last error message.
Definition STK_IRunner.h:82
Abstract class for all classes making supervised learning.
~IRunnerSupervised()
destructor
virtual bool run()=0
run the computations.
IRunnerSupervised(IRunnerSupervised const &runner)
copy constructor
virtual void setY(YArray_ const &y)
set the data set.
virtual bool run(Weights_ const &weights)=0
run the weighted computations.
virtual void updateX()
update the runner when x data set is set.
YArray_ const * p_y_
A pointer on the y data set.
virtual void updateY()
update the runner when y data set is set.
virtual void update()
update the runner.
virtual void setData(YArray_ const &y, XArray_ const &x)
set the data set.
virtual void setX(XArray_ const &x)
set the x data set (predictors).
IRunnerSupervised()
default constructor
XArray_ const * p_x_
A pointer on the x data set.
IRunnerSupervised(YArray_ const &y, XArray_ const &x)
default constructor
IRunnerSupervised(YArray_ const *const &p_y, XArray_ const *const &p_x)
constructor
Abstract class for all classes making unsupervised learning.
virtual void setData(Array const *p_data)
Set the data set.
virtual void setData(Array const &data)
Set the data set.
virtual bool run()=0
run the computations.
virtual bool run(Weights_ const &weights)=0
run the weighted computations.
IRunnerUnsupervised(IRunnerUnsupervised const &runner)
copy constructor
Array const * p_data() const
get the data set
IRunnerUnsupervised(Array const &data)
constructor with a constant reference on the data set
Array const * p_data_
A pointer on the original data set.
IRunnerUnsupervised()
default constructor.
~IRunnerUnsupervised()
destructor
IRunnerUnsupervised(Array const *const p_data)
constructor with a pointer on the constant data set
Abstract class for all running class based on a data set.
IRunnerWithData(Array const &data)
constructor with a constant reference on the data set
IRunnerWithData()
default constructor.
IRunnerWithData(Array const *const p_data)
constructor with a pointer on the constant data set
~IRunnerWithData()
destructor
Array const * p_data_
A pointer on the original data set.
Array const * p_data() const
get the data set
virtual void setData(Array const &data)
Set the data set.
IRunnerWithData(IRunnerWithData const &runner)
copy constructor
virtual void setData(Array const *p_data)
Set the data set.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
std::basic_string< Char > String
STK fundamental type of a String.
The namespace STK is the main domain space of the Statistical ToolKit project.