C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

linear_regression_training_online.h
1 /* file: linear_regression_training_online.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the interface for linear regression model-based training
21 // in the online processing mode
22 //--
23 */
24 
25 #ifndef __LINEAR_REGRESSION_TRAINING_ONLINE_H__
26 #define __LINEAR_REGRESSION_TRAINING_ONLINE_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "algorithms/linear_regression/linear_regression_training_types.h"
30 #include "algorithms/linear_model/linear_model_training_online.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace linear_regression
37 {
38 namespace training
39 {
40 
41 namespace interface1
42 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class OnlineContainer : public TrainingContainerIface<online>
55 {
56 public:
62  OnlineContainer(daal::services::Environment::env *daalEnv);
64  ~OnlineContainer();
65 
72  services::Status compute() DAAL_C11_OVERRIDE;
79  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
80 };
81 
100 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
101 class DAAL_EXPORT Online : public linear_model::training::Online
102 {
103 public:
104  typedef algorithms::linear_regression::training::Input InputType;
105  typedef algorithms::linear_regression::Parameter ParameterType;
106  typedef algorithms::linear_regression::training::Result ResultType;
107  typedef algorithms::linear_regression::training::PartialResult PartialResultType;
108 
109  InputType input;
110  ParameterType parameter;
113  Online()
114  {
115  initialize();
116  }
117 
124  Online(const Online<algorithmFPType, method> &other) :
125  linear_model::training::Online(other), input(other.input), parameter(other.parameter)
126  {
127  initialize();
128  }
129 
130  ~Online() {}
131 
132  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
133 
138  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
139 
144  PartialResultPtr getPartialResult() { return PartialResultType::cast(_partialResult); }
145 
150  ResultPtr getResult() { return ResultType::cast(_result); }
151 
158  services::SharedPtr<Online<algorithmFPType, method> > clone() const
159  {
160  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
161  }
162 
163 protected:
164  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
165  {
166  return new Online<algorithmFPType, method>(*this);
167  }
168 
169  services::Status allocateResult() DAAL_C11_OVERRIDE
170  {
171  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
172  _res = _result.get();
173  return s;
174  }
175 
176  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
177  {
178  services::Status s = getPartialResult()->template allocate<algorithmFPType>(&input, &parameter, method);
179  _pres = _partialResult.get();
180  return s;
181  }
182 
183  services::Status initializePartialResult() DAAL_C11_OVERRIDE
184  {
185  services::Status s = getPartialResult()->template initialize<algorithmFPType>(&input, &parameter, method);
186  _pres = _partialResult.get();
187  return s;
188  }
189 
190  void initialize()
191  {
192  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
193  _in = &input;
194  _par = &parameter;
195  _partialResult.reset(new PartialResultType());
196  _result.reset(new ResultType());
197  }
198 }; // class : public Training
200 } // namespace interface1
201 using interface1::OnlineContainer;
202 using interface1::Online;
203 
204 }
205 }
206 }
207 }
208 #endif
daal::algorithms::linear_regression::training::interface1::Online::getResult
ResultPtr getResult()
Definition: linear_regression_training_online.h:150
daal::algorithms::linear_regression::training::interface1::Online::parameter
ParameterType parameter
Definition: linear_regression_training_online.h:110
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:54
daal::algorithms::linear_regression::training::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_online.h:138
daal::online
Definition: daal_defines.h:114
daal::algorithms::linear_regression::training::interface1::OnlineContainer::OnlineContainer
OnlineContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::linear_regression::training::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: linear_regression_training_online.h:144
daal::algorithms::linear_regression::training::interface1::Online::Online
Online()
Definition: linear_regression_training_online.h:113
daal::algorithms::linear_regression::training::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: linear_regression_training_online.h:158
daal::algorithms::linear_regression::training::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: linear_regression_training_online.h:124
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:101
daal::algorithms::linear_regression::training::interface1::Online::input
InputType input
Definition: linear_regression_training_online.h:109
daal::algorithms::linear_regression::training::interface1::OnlineContainer::finalizeCompute
services::Status finalizeCompute() DAAL_C11_OVERRIDE
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::linear_regression::training::interface1::OnlineContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::linear_regression::training::interface1::OnlineContainer::~OnlineContainer
~OnlineContainer()

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