C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

ridge_regression_training_online.h
1 /* file: ridge_regression_training_online.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for ridge regression model-based training in the online processing mode
19 //--
20 */
21 
22 #ifndef __RIDGE_REGRESSION_TRAINING_ONLINE_H__
23 #define __RIDGE_REGRESSION_TRAINING_ONLINE_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/ridge_regression/ridge_regression_training_types.h"
27 #include "algorithms/linear_model/linear_model_training_online.h"
28 
29 namespace daal
30 {
31 namespace algorithms
32 {
33 namespace ridge_regression
34 {
35 namespace training
36 {
37 namespace interface1
38 {
48 template<typename algorithmFPType, Method method, CpuType cpu>
49 class DAAL_EXPORT OnlineContainer : public TrainingContainerIface<online>
50 {
51 public:
56  OnlineContainer(daal::services::Environment::env *daalEnv);
57 
59  ~OnlineContainer();
60 
66  services::Status compute() DAAL_C11_OVERRIDE;
67 
73  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
74 };
75 
94 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
95 class DAAL_EXPORT Online : public linear_model::training::Online
96 {
97 public:
98  typedef algorithms::ridge_regression::training::Input InputType;
99  typedef algorithms::ridge_regression::TrainParameter ParameterType;
100  typedef algorithms::ridge_regression::training::Result ResultType;
101  typedef algorithms::ridge_regression::training::PartialResult PartialResultType;
102 
103  InputType input;
104  ParameterType parameter;
107  Online()
108  {
109  initialize();
110  }
111 
117  Online(const Online<algorithmFPType, method> & other) :
118  linear_model::training::Online(other), input(other.input), parameter(other.parameter)
119  {
120  initialize();
121  }
122 
123  ~Online() {}
124 
125  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
126 
131  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
132 
137  PartialResultPtr getPartialResult() { return PartialResultType::cast(_partialResult); }
138 
143  ResultPtr getResult() { return ResultType::cast(_result); }
144 
150  services::SharedPtr<Online<algorithmFPType, method> > clone() const
151  {
152  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
153  }
154 
155 protected:
156 
157  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
158  {
159  return new Online<algorithmFPType, method>(*this);
160  }
161 
162  services::Status allocateResult() DAAL_C11_OVERRIDE
163  {
164  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
165  _res = _result.get();
166  return s;
167  }
168 
169  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
170  {
171  services::Status s = getPartialResult()->template allocate<algorithmFPType>(&input, &parameter, method);
172  _pres = _partialResult.get();
173  return s;
174  }
175 
176  services::Status initializePartialResult() DAAL_C11_OVERRIDE
177  {
178  services::Status s = getPartialResult()->template initialize<algorithmFPType>(&input, &parameter, method);
179  _pres = _partialResult.get();
180  return s;
181  }
182 
183  void initialize()
184  {
185  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
186  _in = &input;
187  _par = &parameter;
188  _partialResult.reset(new PartialResultType());
189  _result.reset(new ResultType());
190  }
191 }; // class : Online
193 } // namespace interface1
194 
195 using interface1::OnlineContainer;
196 using interface1::Online;
197 
198 } // namespace training
199 } // namespace ridge_regression
200 } // namespace algorithms
201 } // namespace daal
202 
203 #endif
daal::algorithms::ridge_regression::training::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: ridge_regression_training_online.h:131
daal::algorithms::ridge_regression::training::interface1::Online::getResult
ResultPtr getResult()
Definition: ridge_regression_training_online.h:143
daal::algorithms::ridge_regression::training::interface1::Online::parameter
ParameterType parameter
Definition: ridge_regression_training_online.h:104
daal
Definition: algorithm_base_common.h:31
daal::algorithms::ridge_regression::training::interface1::OnlineContainer
Class containing methods for ridge regression model-based training in the online processing mode...
Definition: ridge_regression_training_online.h:49
daal::algorithms::ridge_regression::training::interface1::Online
Provides methods for ridge regression model-based training in the online processing mode...
Definition: ridge_regression_training_online.h:95
daal::algorithms::ridge_regression::training::interface1::Online::Online
Online()
Definition: ridge_regression_training_online.h:107
daal::algorithms::ridge_regression::training::interface1::Online::input
InputType input
Definition: ridge_regression_training_online.h:103
daal::algorithms::ridge_regression::training::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: ridge_regression_training_online.h:137
daal::algorithms::ridge_regression::training::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: ridge_regression_training_online.h:150
daal::online
Definition: daal_defines.h:108
daal::algorithms::ridge_regression::training::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: ridge_regression_training_online.h:117
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50

For more complete information about compiler optimizations, see our Optimization Notice.