C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 5

linear_regression_training_batch.h
1 /* file: linear_regression_training_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for linear regression model-based training
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __LINEAR_REGRESSION_TRAINING_BATCH_H__
24 #define __LINEAR_REGRESSION_TRAINING_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "services/daal_defines.h"
28 #include "services/daal_memory.h"
29 #include "algorithms/linear_regression/linear_regression_training_types.h"
30 #include "algorithms/linear_regression/linear_regression_model.h"
31 #include "algorithms/linear_model/linear_model_training_batch.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace linear_regression
38 {
39 namespace training
40 {
41 
42 namespace interface1
43 {
54 template<typename algorithmFPType, Method method, CpuType cpu>
55 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
56 {
57 public:
63  BatchContainer(daal::services::Environment::env *daalEnv);
65  ~BatchContainer();
71  services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
91 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
92 class DAAL_EXPORT Batch : public linear_model::training::Batch
93 {
94 public:
95  typedef algorithms::linear_regression::training::Input InputType;
96  typedef algorithms::linear_regression::Parameter ParameterType;
97  typedef algorithms::linear_regression::training::Result ResultType;
98 
99  InputType input;
100  ParameterType parameter;
103  Batch()
104  {
105  initialize();
106  }
107 
114  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
115  {
116  initialize();
117  }
118 
119  ~Batch() {}
120 
121  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
122 
127  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
128 
133  ResultPtr getResult() { return ResultType::cast(_result); }
134 
141  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
142  {
143  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
144  }
145 
146 protected:
147  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
148  {
149  return new Batch<algorithmFPType, method>(*this);
150  }
151 
152  services::Status allocateResult() DAAL_C11_OVERRIDE
153  {
154  services::Status s = getResult()->template allocate<algorithmFPType>(&input, &parameter, method);
155  _res = _result.get();
156  return s;
157  }
158 
159  void initialize()
160  {
161  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
162  _in = &input;
163  _par = &parameter;
164  _result.reset(new ResultType());
165  }
166 };
168 } // namespace interface1
169 using interface1::BatchContainer;
170 using interface1::Batch;
171 
172 }
173 }
174 }
175 }
176 #endif
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:92
daal::algorithms::linear_regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: linear_regression_training_batch.h:133
daal
Definition: algorithm_base_common.h:31
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:55
daal::algorithms::linear_regression::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: linear_regression_training_batch.h:114
daal_defines.h
daal::algorithms::linear_regression::training::interface1::Batch::parameter
ParameterType parameter
Definition: linear_regression_training_batch.h:100
daal::algorithms::linear_regression::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: linear_regression_training_batch.h:141
daal::batch
Definition: daal_defines.h:110
daal::algorithms::linear_regression::training::interface1::Batch::Batch
Batch()
Definition: linear_regression_training_batch.h:103
daal::algorithms::linear_regression::training::interface1::Batch::input
InputType input
Definition: linear_regression_training_batch.h:99
daal::algorithms::linear_regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_batch.h:127
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50

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