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

ridge_regression_training_online.h
1 /* file: ridge_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 ridge regression model-based training in the online processing mode
45 //--
46 */
47 
48 #ifndef __RIDGE_REGRESSION_TRAINING_ONLINE_H__
49 #define __RIDGE_REGRESSION_TRAINING_ONLINE_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "algorithms/ridge_regression/ridge_regression_training_types.h"
53 #include "algorithms/linear_model/linear_model_training_online.h"
54 
55 namespace daal
56 {
57 namespace algorithms
58 {
59 namespace ridge_regression
60 {
61 namespace training
62 {
63 namespace interface1
64 {
74 template<typename algorithmFPType, Method method, CpuType cpu>
75 class DAAL_EXPORT OnlineContainer : public TrainingContainerIface<online>
76 {
77 public:
82  OnlineContainer(daal::services::Environment::env *daalEnv);
83 
85  ~OnlineContainer();
86 
92  services::Status compute() DAAL_C11_OVERRIDE;
93 
99  services::Status finalizeCompute() DAAL_C11_OVERRIDE;
100 };
101 
120 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
121 class DAAL_EXPORT Online : public linear_model::training::Online
122 {
123 public:
124  typedef algorithms::ridge_regression::training::Input InputType;
125  typedef algorithms::ridge_regression::TrainParameter ParameterType;
126  typedef algorithms::ridge_regression::training::Result ResultType;
127  typedef algorithms::ridge_regression::training::PartialResult PartialResultType;
128 
129  InputType input;
130  ParameterType parameter;
133  Online()
134  {
135  initialize();
136  }
137 
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 PartialResultType::cast(_partialResult); }
164 
169  ResultPtr getResult() { return ResultType::cast(_result); }
170 
176  services::SharedPtr<Online<algorithmFPType, method> > clone() const
177  {
178  return services::SharedPtr<Online<algorithmFPType, method> >(cloneImpl());
179  }
180 
181 protected:
182 
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 PartialResultType());
215  _result.reset(new ResultType());
216  }
217 }; // class : Online
219 } // namespace interface1
220 
221 using interface1::OnlineContainer;
222 using interface1::Online;
223 
224 } // namespace training
225 } // namespace ridge_regression
226 } // namespace algorithms
227 } // namespace daal
228 
229 #endif
daal::algorithms::ridge_regression::training::interface1::Online::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: ridge_regression_training_online.h:157
daal::algorithms::ridge_regression::training::interface1::Online::getResult
ResultPtr getResult()
Definition: ridge_regression_training_online.h:169
daal::algorithms::regression::training::interface1::Input
Input objects for the regression model-based training
Definition: regression_training_types.h:102
daal::algorithms::ridge_regression::training::interface1::Online::parameter
ParameterType parameter
Definition: ridge_regression_training_online.h:130
daal::algorithms::ridge_regression::training::interface1::Online::clone
services::SharedPtr< Online< algorithmFPType, method > > clone() const
Definition: ridge_regression_training_online.h:176
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::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:75
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:121
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::ridge_regression::training::interface1::Online::Online
Online()
Definition: ridge_regression_training_online.h:133
daal::algorithms::linear_model::interface1::Parameter
Parameters for the regression algorithm.
Definition: linear_model_model.h:85
daal::algorithms::ridge_regression::interface1::TrainParameter
Parameters for the ridge regression algorithm.
Definition: ridge_regression_model.h:94
daal::algorithms::linear_model::training::interface1::Input
Input objects for the regression model-based training
Definition: linear_model_training_types.h:103
daal::algorithms::ridge_regression::training::interface1::Online::input
InputType input
Definition: ridge_regression_training_online.h:129
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::ridge_regression::training::interface1::PartialResult
Provides methods to access a partial result obtained with the compute() method of ridge regression mo...
Definition: ridge_regression_training_types.h:216
daal::algorithms::ridge_regression::training::interface1::Online::getPartialResult
PartialResultPtr getPartialResult()
Definition: ridge_regression_training_online.h:163
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::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::ridge_regression::training::interface1::Result
Provides methods to access the result obtained with the compute() method of ridge regression model-ba...
Definition: ridge_regression_training_types.h:358
daal::algorithms::ridge_regression::training::interface1::Online::Online
Online(const Online< algorithmFPType, method > &other)
Definition: ridge_regression_training_online.h:143
daal::algorithms::ridge_regression::training::interface1::Input
Input objects for ridge regression model-based training
Definition: ridge_regression_training_types.h:158
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:76

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