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

linear_regression_group_of_betas_batch.h
1 /* file: linear_regression_group_of_betas_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 // Interface of the linear regression group of betas quality metric in the batch processing mode.
19 //--
20 */
21 
22 #ifndef __LINEAR_REGRESSION_GROUP_OF_BETAS_BATCH_H__
23 #define __LINEAR_REGRESSION_GROUP_OF_BETAS_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/linear_regression/linear_regression_group_of_betas_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace linear_regression
33 {
37 namespace quality_metric
38 {
42 namespace group_of_betas
43 {
44 namespace interface1
45 {
58 template<typename algorithmFPType, Method method, CpuType cpu>
59 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
60 {
61 public:
63  BatchContainer(daal::services::Environment::env *daalEnv);
65  virtual ~BatchContainer();
66 
72  virtual services::Status compute() DAAL_C11_OVERRIDE;
73 };
74 
87 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
88 class DAAL_EXPORT Batch : public daal::algorithms::quality_metric::Batch
89 {
90 public:
91  typedef algorithms::linear_regression::quality_metric::group_of_betas::Input InputType;
92  typedef algorithms::linear_regression::quality_metric::group_of_betas::Parameter ParameterType;
93  typedef algorithms::linear_regression::quality_metric::group_of_betas::Result ResultType;
94 
95  InputType input;
96  ParameterType parameter;
99  Batch(size_t nBeta, size_t nBetaReducedModel) : parameter(nBeta, nBetaReducedModel)
100  {
101  initialize();
102  }
103 
110  Batch(const Batch<algorithmFPType, method> &other): parameter(other.parameter)
111  {
112  initialize();
113  input.set(expectedResponses, other.input.get(expectedResponses));
114  input.set(predictedResponses, other.input.get(predictedResponses));
115  input.set(predictedReducedModelResponses, other.input.get(predictedReducedModelResponses));
116  }
117 
122  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
123 
128  ResultPtr getResult() const
129  {
130  return _result;
131  }
132 
139  services::Status setResult(const ResultPtr& result)
140  {
141  DAAL_CHECK(result, services::ErrorNullResult)
142  _result = result;
143  _res = _result.get();
144  return services::Status();
145  }
146 
151  virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
152  {
153  const InputType *inputPtr = static_cast<const InputType *>(other);
154  input.set(expectedResponses, inputPtr->get(expectedResponses));
155  input.set(predictedResponses, inputPtr->get(predictedResponses));
156  input.set(predictedReducedModelResponses, inputPtr->get(predictedReducedModelResponses));
157  }
158 
164  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
165  {
166  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
167  }
168 
169 protected:
170  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
171  {
172  return new Batch<algorithmFPType, method>(*this);
173  }
174 
175  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
176  {
177  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
178  _res = _result.get();
179  return s;
180  }
181 
182  virtual algorithms::ResultPtr getResultImpl() const DAAL_C11_OVERRIDE
183  {
184  return _result;
185  }
186 
187  void initialize()
188  {
189  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
190  _in = &input;
191  _par = &parameter;
192  _result.reset(new ResultType());
193  }
194 
195 private:
196  ResultPtr _result;
197 };
199 } // namespace interface1
200 using interface1::BatchContainer;
201 using interface1::Batch;
202 
203 }
204 }
205 }
206 }
207 }
208 #endif
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::parameter
ParameterType parameter
Definition: linear_regression_group_of_betas_batch.h:96
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::input
InputType input
Definition: linear_regression_group_of_betas_batch.h:95
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::getResult
ResultPtr getResult() const
Definition: linear_regression_group_of_betas_batch.h:128
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::setInput
virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
Definition: linear_regression_group_of_betas_batch.h:151
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: linear_regression_group_of_betas_batch.h:164
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: linear_regression_group_of_betas_batch.h:110
daal::algorithms::linear_regression::quality_metric::group_of_betas::predictedReducedModelResponses
Definition: linear_regression_group_of_betas_types.h:63
daal::batch
Definition: daal_defines.h:106
daal::algorithms::linear_regression::quality_metric::group_of_betas::expectedResponses
Definition: linear_regression_group_of_betas_types.h:61
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::Batch
Batch(size_t nBeta, size_t nBetaReducedModel)
Definition: linear_regression_group_of_betas_batch.h:99
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch
Computes the linear regression quality metric in the batch processing mode.
Definition: linear_regression_group_of_betas_batch.h:88
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: linear_regression_group_of_betas_batch.h:139
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::BatchContainer
Class containing methods to compute regression quality metric.
Definition: linear_regression_group_of_betas_batch.h:59
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::linear_regression::quality_metric::group_of_betas::predictedResponses
Definition: linear_regression_group_of_betas_types.h:62
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_group_of_betas_batch.h:122
daal::services::ErrorNullResult
Definition: error_indexes.h:96

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