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

linear_regression_training_online.h
1 /* file: linear_regression_training_online.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 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  Input input;
129  Parameter parameter;
132  Online()
133  {
134  initialize();
135  }
136 
143  Online(const Online<algorithmFPType, method> &other) :
144  linear_model::training::Online(other), input(other.input), parameter(other.parameter)
145  {
146  initialize();
147  }
148 
149  ~Online() {}
150 
151  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
152 
157  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
158 
163  PartialResultPtr getPartialResult() { return PartialResult::cast(_partialResult); }
164 
169  ResultPtr getResult() { return Result::cast(_result); }
170 
177  services::SharedPtr<Online<algorithmFPType, method> > clone() const
178  {
179  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
180  }
181 
182 protected:
183  virtual Online<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
184  {
185  return new Online<algorithmFPType, method>(*this);
186  }
187 
188  services::Status allocateResult() DAAL_C11_OVERRIDE
189  {
190  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
191  _res = _result.get();
192  return s;
193  }
194 
195  services::Status allocatePartialResult() DAAL_C11_OVERRIDE
196  {
197  services::Status s = getPartialResult()->template allocate<algorithmFPType>(&input, &parameter, method);
198  _pres = _partialResult.get();
199  return s;
200  }
201 
202  services::Status initializePartialResult() DAAL_C11_OVERRIDE
203  {
204  services::Status s = getPartialResult()->template initialize<algorithmFPType>(&input, &parameter, method);
205  _pres = _partialResult.get();
206  return s;
207  }
208 
209  void initialize()
210  {
211  _ac = new __DAAL_ALGORITHM_CONTAINER(online, OnlineContainer, algorithmFPType, method)(&_env);
212  _in = &input;
213  _par = &parameter;
214  _partialResult.reset(new PartialResult());
215  _result.reset(new Result());
216  }
217 }; // class : public Training
219 } // namespace interface1
220 using interface1::OnlineContainer;
221 using interface1::Online;
222 
223 }
224 }
225 }
226 }
227 #endif
daal::algorithms::linear_regression::training::interface1::Online::parameter
Parameter parameter
Definition: linear_regression_training_online.h:129
daal
Definition: algorithm_base_common.h:57
daal::algorithms::linear_regression::training::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: linear_regression_training_online.h:163
daal::algorithms::linear_regression::training::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: linear_regression_training_online.h:143
daal::algorithms::linear_regression::training::interface1::Online::Online
Online()
Definition: linear_regression_training_online.h:132
daal::algorithms::linear_regression::training::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: linear_regression_training_online.h:177
daal::algorithms::linear_regression::training::interface1::Online::getResult
ResultPtr getResult()
Definition: linear_regression_training_online.h:169
daal::algorithms::linear_regression::training::interface1::Online::input
Input input
Definition: linear_regression_training_online.h:128
daal::algorithms::linear_regression::training::interface1::Input
Input objects for linear regression model-based training
Definition: linear_regression_training_types.h:160
daal::online
Definition: daal_defines.h:133
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:157
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.