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

linear_regression_training_batch.h
1 /* file: linear_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 linear regression model-based training
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __LINEAR_REGRESSION_TRAINING_BATCH_H__
26 #define __LINEAR_REGRESSION_TRAINING_BATCH_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "services/daal_defines.h"
30 #include "services/daal_memory.h"
31 #include "algorithms/linear_regression/linear_regression_training_types.h"
32 #include "algorithms/linear_regression/linear_regression_model.h"
33 #include "algorithms/linear_model/linear_model_training_batch.h"
34 
35 namespace daal
36 {
37 namespace algorithms
38 {
39 namespace linear_regression
40 {
41 namespace training
42 {
43 
44 namespace interface1
45 {
56 template<typename algorithmFPType, Method method, CpuType cpu>
57 class BatchContainer : public TrainingContainerIface<batch>
58 {
59 public:
65  BatchContainer(daal::services::Environment::env *daalEnv);
67  ~BatchContainer();
73  services::Status compute() DAAL_C11_OVERRIDE;
74 };
75 
93 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
94 class DAAL_EXPORT Batch : public linear_model::training::Batch
95 {
96 public:
97  typedef algorithms::linear_regression::training::Input InputType;
98  typedef algorithms::linear_regression::Parameter ParameterType;
99  typedef algorithms::linear_regression::training::Result ResultType;
100 
101  InputType input;
102  ParameterType parameter;
105  Batch()
106  {
107  initialize();
108  }
109 
116  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
117  {
118  initialize();
119  }
120 
121  ~Batch() {}
122 
123  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
124 
129  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
130 
135  ResultPtr getResult() { return ResultType::cast(_result); }
136 
140  services::Status resetResult() DAAL_C11_OVERRIDE
141  {
142  _result.reset(new ResultType());
143  DAAL_CHECK(_result, services::ErrorNullResult);
144  _res = NULL;
145  return services::Status();
146  }
147 
154  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
155  {
156  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
157  }
158 
159 protected:
160  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
161  {
162  return new Batch<algorithmFPType, method>(*this);
163  }
164 
165  services::Status allocateResult() DAAL_C11_OVERRIDE
166  {
167  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
168  _res = _result.get();
169  return s;
170  }
171 
172  void initialize()
173  {
174  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
175  _in = &input;
176  _par = &parameter;
177  _result.reset(new ResultType());
178  }
179 };
181 } // namespace interface1
182 using interface1::BatchContainer;
183 using interface1::Batch;
184 
185 }
186 }
187 }
188 }
189 #endif
daal::algorithms::linear_regression::training::interface1::BatchContainer
Class containing methods for normal equations linear regression model-based training using algorithmF...
Definition: linear_regression_training_batch.h:57
daal::batch
Definition: daal_defines.h:112
daal::algorithms::linear_regression::training::interface1::Batch
Provides methods for linear regression model-based training in the batch processing mode...
Definition: linear_regression_training_batch.h:94
daal::algorithms::linear_regression::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: linear_regression_training_batch.h:116
daal::algorithms::linear_regression::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: linear_regression_training_batch.h:154
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::linear_regression::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::linear_regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: linear_regression_training_batch.h:135
daal_defines.h
daal::algorithms::linear_regression::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: linear_regression_training_batch.h:140
daal::algorithms::linear_regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_batch.h:129
daal::algorithms::linear_regression::training::interface1::Batch::parameter
ParameterType parameter
Definition: linear_regression_training_batch.h:102
daal::algorithms::linear_regression::training::interface1::Batch::Batch
Batch()
Definition: linear_regression_training_batch.h:105
daal::algorithms::linear_regression::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::linear_regression::training::interface1::BatchContainer::compute
services::Status compute() 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::Batch::input
InputType input
Definition: linear_regression_training_batch.h:101

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