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

linear_regression_training_online.h
1 /* file: linear_regression_training_online.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the interface for linear regression model-based training
45 // in the online processing mode
46 //--
47 */
48 
49 #ifndef __LINEAR_REGRESSION_TRAINING_ONLINE_H__
50 #define __LINEAR_REGRESSION_TRAINING_ONLINE_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "algorithms/linear_regression/linear_regression_training_types.h"
54 #include "algorithms/linear_model/linear_model_training_online.h"
55 
56 namespace daal
57 {
58 namespace algorithms
59 {
60 namespace linear_regression
61 {
62 namespace training
63 {
64 
65 namespace interface1
66 {
77 template<typename algorithmFPType, Method method, CpuType cpu>
78 class DAAL_EXPORT OnlineContainer : public TrainingContainerIface<online>
79 {
80 public:
86  OnlineContainer(daal::services::Environment::env *daalEnv);
88  ~OnlineContainer();
89 
96  services::Status compute() DAAL_C11_OVERRIDE;
103  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
104 };
105 
124 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
125 class DAAL_EXPORT Online : public linear_model::training::Online
126 {
127 public:
128  typedef algorithms::linear_regression::training::Input InputType;
129  typedef algorithms::linear_regression::Parameter ParameterType;
130  typedef algorithms::linear_regression::training::Result ResultType;
131  typedef algorithms::linear_regression::training::PartialResult PartialResultType;
132 
133  InputType input;
134  ParameterType parameter;
137  Online()
138  {
139  initialize();
140  }
141 
148  Online(const Online<algorithmFPType, method> &other) :
149  linear_model::training::Online(other), input(other.input), parameter(other.parameter)
150  {
151  initialize();
152  }
153 
154  ~Online() {}
155 
156  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
157 
162  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
163 
168  PartialResultPtr getPartialResult() { return PartialResultType::cast(_partialResult); }
169 
174  ResultPtr getResult() { return ResultType::cast(_result); }
175 
182  services::SharedPtr<Online<algorithmFPType, method> > clone() const
183  {
184  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
185  }
186 
187 protected:
188  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
189  {
190  return new Online<algorithmFPType, method>(*this);
191  }
192 
193  services::Status allocateResult() DAAL_C11_OVERRIDE
194  {
195  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
196  _res = _result.get();
197  return s;
198  }
199 
200  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
201  {
202  services::Status s = getPartialResult()->template allocate<algorithmFPType>(&input, &parameter, method);
203  _pres = _partialResult.get();
204  return s;
205  }
206 
207  services::Status initializePartialResult() DAAL_C11_OVERRIDE
208  {
209  services::Status s = getPartialResult()->template initialize<algorithmFPType>(&input, &parameter, method);
210  _pres = _partialResult.get();
211  return s;
212  }
213 
214  void initialize()
215  {
216  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
217  _in = &input;
218  _par = &parameter;
219  _partialResult.reset(new PartialResultType());
220  _result.reset(new ResultType());
221  }
222 }; // class : public Training
224 } // namespace interface1
225 using interface1::OnlineContainer;
226 using interface1::Online;
227 
228 }
229 }
230 }
231 }
232 #endif
daal::algorithms::regression::training::interface1::Input
Input objects for the regression model-based training
Definition: regression_training_types.h:102
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::linear_regression::training::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: linear_regression_training_online.h:168
daal::algorithms::linear_regression::training::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: linear_regression_training_online.h:148
daal::algorithms::linear_regression::training::interface1::Online::Online
Online()
Definition: linear_regression_training_online.h:137
daal::algorithms::linear_model::training::interface1::Result
Provides methods to access the result obtained with the compute() method of the regression model-base...
Definition: linear_model_training_types.h:174
daal::algorithms::linear_model::interface1::Parameter
Parameters for the regression algorithm.
Definition: linear_model_model.h:85
daal::algorithms::linear_model::training::interface1::Input
Input objects for the regression model-based training
Definition: linear_model_training_types.h:103
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::linear_regression::training::interface1::Result
Provides methods to access the result obtained with the compute() method of linear regression model-b...
Definition: linear_regression_training_types.h:361
daal::algorithms::linear_regression::training::interface1::Online::input
InputType input
Definition: linear_regression_training_online.h:133
daal::algorithms::linear_regression::training::interface1::Online::parameter
ParameterType parameter
Definition: linear_regression_training_online.h:134
daal::algorithms::linear_regression::training::interface1::Online::getResult
ResultPtr getResult()
Definition: linear_regression_training_online.h:174
daal::algorithms::linear_model::training::interface1::PartialResult
Provides methods to access a partial result obtained with the compute() method of the linear model-ba...
Definition: linear_model_training_types.h:135
daal::algorithms::linear_regression::training::interface1::PartialResult
Provides methods to access a partial result obtained with the compute() method of linear regression m...
Definition: linear_regression_training_types.h:218
daal::algorithms::linear_regression::training::interface1::Input
Input objects for linear regression model-based training
Definition: linear_regression_training_types.h:160
daal::algorithms::linear_regression::training::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: linear_regression_training_online.h:182
daal::algorithms::linear_regression::interface1::Parameter
Parameters for the linear regression algorithm.
Definition: linear_regression_model.h:82
daal::online
Definition: daal_defines.h:134
daal::algorithms::linear_model::training::interface1::Online
Provides methods for the linear model-based training in the online processing mode.
Definition: linear_model_training_online.h:80
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:125
daal::algorithms::linear_regression::training::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_online.h:162
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:76
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:78

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