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

ridge_regression_training_batch.h
1 /* file: ridge_regression_training_batch.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 ridge regression model-based training in the batch processing mode
21 //--
22 */
23 
24 #ifndef __RIDGE_REGRESSION_TRAINING_BATCH_H__
25 #define __RIDGE_REGRESSION_TRAINING_BATCH_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "services/daal_defines.h"
29 #include "services/daal_memory.h"
30 #include "algorithms/ridge_regression/ridge_regression_training_types.h"
31 #include "algorithms/ridge_regression/ridge_regression_model.h"
32 #include "algorithms/linear_model/linear_model_training_batch.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace ridge_regression
39 {
40 namespace training
41 {
42 namespace interface1
43 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class BatchContainer : public TrainingContainerIface<batch>
55 {
56 public:
61  BatchContainer(daal::services::Environment::env *daalEnv);
62 
64  ~BatchContainer();
65 
71  services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
90 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
91 class DAAL_EXPORT Batch : public linear_model::training::Batch
92 {
93 public:
94  typedef algorithms::ridge_regression::training::Input InputType;
95  typedef algorithms::ridge_regression::TrainParameter ParameterType;
96  typedef algorithms::ridge_regression::training::Result ResultType;
97 
98  InputType input;
99  ParameterType parameter;
102  Batch()
103  {
104  initialize();
105  }
106 
113  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
114  {
115  initialize();
116  }
117 
118  ~Batch() {}
119 
120  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
121 
126  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
127 
132  ResultPtr getResult() { return ResultType::cast(_result); }
133 
134  /* Resets the results of the regression model-based training
135  * \return Status of the operation
136  */
137  virtual services::Status resetResult() DAAL_C11_OVERRIDE
138  {
139  _result.reset(new ResultType());
140  DAAL_CHECK(_result, services::ErrorNullResult)
141  _res = NULL;
142  return services::Status();
143  }
150  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
151  {
152  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
153  }
154 
155 protected:
156 
157  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
158  {
159  return new Batch<algorithmFPType, method>(*this);
160  }
161 
162  services::Status allocateResult() DAAL_C11_OVERRIDE
163  {
164  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
165  _res = _result.get();
166  return s;
167  }
168 
169  void initialize()
170  {
171  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
172  _in = &input;
173  _par = &parameter;
174  _result.reset(new ResultType());
175  }
176 };
178 } // namespace interface1
179 
180 using interface1::BatchContainer;
181 using interface1::Batch;
182 
183 } // namespace training
184 } // namespace ridge_regression
185 } // namespace algorithms
186 } // namespace daal
187 
188 #endif
daal::algorithms::ridge_regression::training::interface1::Batch::input
InputType input
Definition: ridge_regression_training_batch.h:98
daal::batch
Definition: daal_defines.h:112
daal::algorithms::ridge_regression::training::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::ridge_regression::training::interface1::Batch::parameter
ParameterType parameter
Definition: ridge_regression_training_batch.h:99
daal::algorithms::ridge_regression::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::ridge_regression::training::interface1::Batch
Provides methods for ridge regression model-based training in the batch processing mode...
Definition: ridge_regression_training_batch.h:91
daal::algorithms::ridge_regression::training::interface1::BatchContainer
Class containing methods for normal equations ridge regression model-based training using algorithmFP...
Definition: ridge_regression_training_batch.h:54
daal_defines.h
daal::algorithms::ridge_regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: ridge_regression_training_batch.h:132
daal::algorithms::ridge_regression::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::ridge_regression::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: ridge_regression_training_batch.h:113
daal::algorithms::ridge_regression::training::interface1::Batch::Batch
Batch()
Definition: ridge_regression_training_batch.h:102
daal::algorithms::ridge_regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: ridge_regression_training_batch.h:126
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52

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