C++ API Reference for Intel® Data Analytics Acceleration Library 2019

linear_regression_training_online.h
1 /* file: linear_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 linear regression model-based training
19 // in the online processing mode
20 //--
21 */
22 
23 #ifndef __LINEAR_REGRESSION_TRAINING_ONLINE_H__
24 #define __LINEAR_REGRESSION_TRAINING_ONLINE_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "algorithms/linear_regression/linear_regression_training_types.h"
28 #include "algorithms/linear_model/linear_model_training_online.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace linear_regression
35 {
36 namespace training
37 {
38 
39 namespace interface1
40 {
51 template<typename algorithmFPType, Method method, CpuType cpu>
52 class DAAL_EXPORT OnlineContainer : public TrainingContainerIface<online>
53 {
54 public:
60  OnlineContainer(daal::services::Environment::env *daalEnv);
62  ~OnlineContainer();
63 
70  services::Status compute() DAAL_C11_OVERRIDE;
77  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
78 };
79 
98 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
99 class DAAL_EXPORT Online : public linear_model::training::Online
100 {
101 public:
102  typedef algorithms::linear_regression::training::Input InputType;
103  typedef algorithms::linear_regression::Parameter ParameterType;
104  typedef algorithms::linear_regression::training::Result ResultType;
105  typedef algorithms::linear_regression::training::PartialResult PartialResultType;
106 
107  InputType input;
108  ParameterType parameter;
111  Online()
112  {
113  initialize();
114  }
115 
122  Online(const Online<algorithmFPType, method> &other) :
123  linear_model::training::Online(other), input(other.input), parameter(other.parameter)
124  {
125  initialize();
126  }
127 
128  ~Online() {}
129 
130  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
131 
136  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
137 
142  PartialResultPtr getPartialResult() { return PartialResultType::cast(_partialResult); }
143 
148  ResultPtr getResult() { return ResultType::cast(_result); }
149 
156  services::SharedPtr<Online<algorithmFPType, method> > clone() const
157  {
158  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
159  }
160 
161 protected:
162  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
163  {
164  return new Online<algorithmFPType, method>(*this);
165  }
166 
167  services::Status allocateResult() DAAL_C11_OVERRIDE
168  {
169  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
170  _res = _result.get();
171  return s;
172  }
173 
174  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
175  {
176  services::Status s = getPartialResult()->template allocate<algorithmFPType>(&input, &parameter, method);
177  _pres = _partialResult.get();
178  return s;
179  }
180 
181  services::Status initializePartialResult() DAAL_C11_OVERRIDE
182  {
183  services::Status s = getPartialResult()->template initialize<algorithmFPType>(&input, &parameter, method);
184  _pres = _partialResult.get();
185  return s;
186  }
187 
188  void initialize()
189  {
190  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
191  _in = &input;
192  _par = &parameter;
193  _partialResult.reset(new PartialResultType());
194  _result.reset(new ResultType());
195  }
196 }; // class : public Training
198 } // namespace interface1
199 using interface1::OnlineContainer;
200 using interface1::Online;
201 
202 }
203 }
204 }
205 }
206 #endif
daal
Definition: algorithm_base_common.h:31
daal::algorithms::linear_regression::training::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: linear_regression_training_online.h:142
daal::algorithms::linear_regression::training::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: linear_regression_training_online.h:122
daal::algorithms::linear_regression::training::interface1::Online::Online
Online()
Definition: linear_regression_training_online.h:111
daal::algorithms::linear_regression::training::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: linear_regression_training_online.h:156
daal::algorithms::linear_regression::training::interface1::Online::input
InputType input
Definition: linear_regression_training_online.h:107
daal::algorithms::linear_regression::training::interface1::Online::parameter
ParameterType parameter
Definition: linear_regression_training_online.h:108
daal::algorithms::linear_regression::training::interface1::Online::getResult
ResultPtr getResult()
Definition: linear_regression_training_online.h:148
daal::online
Definition: daal_defines.h:108
daal::algorithms::linear_regression::training::interface1::Online
Provides methods for linear regression model-based training in the online processing mode...
Definition: linear_regression_training_online.h:99
daal::algorithms::linear_regression::training::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_online.h:136
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50
daal::algorithms::linear_regression::training::interface1::OnlineContainer
Class containing methods for linear regression model-based training in the online processing mode...
Definition: linear_regression_training_online.h:52

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