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

linear_regression_single_beta_batch.h
1 /* file: linear_regression_single_beta_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 // Interface of the linear regression single beta quality metric in the batch processing mode.
19 //--
20 */
21 
22 #ifndef __LINEAR_REGRESSION_SINGLE_BETA_BATCH_H__
23 #define __LINEAR_REGRESSION_SINGLE_BETA_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/linear_regression/linear_regression_single_beta_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace linear_regression
33 {
34 namespace quality_metric
35 {
39 namespace single_beta
40 {
41 
42 namespace interface1
43 {
56 template<typename algorithmFPType, Method method, CpuType cpu>
57 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
58 {
59 public:
61  BatchContainer(daal::services::Environment::env *daalEnv);
63  virtual ~BatchContainer();
64 
70  virtual services::Status compute() DAAL_C11_OVERRIDE;
71 };
72 
85 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
86 class DAAL_EXPORT Batch : public daal::algorithms::quality_metric::Batch
87 {
88 public:
89  typedef algorithms::linear_regression::quality_metric::single_beta::Input InputType;
90  typedef algorithms::linear_regression::quality_metric::single_beta::Parameter ParameterType;
91  typedef algorithms::linear_regression::quality_metric::single_beta::Result ResultType;
92 
93  InputType input;
94  ParameterType parameter;
97  Batch()
98  {
99  initialize();
100  }
101 
108  Batch(const Batch<algorithmFPType, method> &other): parameter(other.parameter)
109  {
110  initialize();
111  input.set(expectedResponses, other.input.get(expectedResponses));
112  input.set(predictedResponses, other.input.get(predictedResponses));
113  input.set(model, other.input.get(model));
114  }
115 
120  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
121 
126  ResultPtr getResult() const
127  {
128  return _result;
129  }
130 
137  services::Status setResult(const ResultPtr& result)
138  {
139  DAAL_CHECK(result, services::ErrorNullResult)
140  _result = result;
141  _res = _result.get();
142  return services::Status();
143  }
144 
149  virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
150  {
151  const InputType *inputPtr = static_cast<const InputType *>(other);
152  input.set(expectedResponses, inputPtr->get(expectedResponses));
153  input.set(predictedResponses, inputPtr->get(predictedResponses));
154  input.set(model, inputPtr->get(model));
155  }
156 
162  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
163  {
164  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
165  }
166 
167 protected:
168  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
169  {
170  return new Batch<algorithmFPType, method>(*this);
171  }
172 
173  services::Status allocateResult() DAAL_C11_OVERRIDE
174  {
175  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
176  _res = _result.get();
177  return s;
178  }
179 
180  virtual algorithms::ResultPtr getResultImpl() const DAAL_C11_OVERRIDE
181  {
182  return _result;
183  }
184 
185  void initialize()
186  {
187  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
188  _in = &input;
189  _par = &parameter;
190  _result.reset(new ResultType());
191  }
192 
193 private:
194  ResultPtr _result;
195 };
197 } // namespace interface1
198 using interface1::BatchContainer;
199 using interface1::Batch;
200 
201 }
202 }
203 }
204 }
205 }
206 #endif
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::BatchContainer
Class containing methods to compute regression quality metric.
Definition: linear_regression_single_beta_batch.h:57
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::single_beta::interface1::Batch
Computes the linear regression quality metric in the batch processing mode.
Definition: linear_regression_single_beta_batch.h:86
daal::algorithms::linear_regression::quality_metric::single_beta::model
Definition: linear_regression_single_beta_types.h:73
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::input
InputType input
Definition: linear_regression_single_beta_batch.h:93
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_single_beta_batch.h:120
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::Batch
Batch()
Definition: linear_regression_single_beta_batch.h:97
daal::batch
Definition: daal_defines.h:110
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::parameter
ParameterType parameter
Definition: linear_regression_single_beta_batch.h:94
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: linear_regression_single_beta_batch.h:162
daal::algorithms::linear_regression::quality_metric::single_beta::expectedResponses
Definition: linear_regression_single_beta_types.h:62
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::setInput
virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
Definition: linear_regression_single_beta_batch.h:149
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: linear_regression_single_beta_batch.h:137
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::single_beta::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: linear_regression_single_beta_batch.h:108
daal::algorithms::linear_regression::quality_metric::single_beta::interface1::Batch::getResult
ResultPtr getResult() const
Definition: linear_regression_single_beta_batch.h:126
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::linear_regression::quality_metric::single_beta::predictedResponses
Definition: linear_regression_single_beta_types.h:63

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