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

linear_regression_group_of_betas_batch.h
1 /* file: linear_regression_group_of_betas_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 // Interface of the linear regression group of betas quality metric in the batch processing mode.
21 //--
22 */
23 
24 #ifndef __LINEAR_REGRESSION_GROUP_OF_BETAS_BATCH_H__
25 #define __LINEAR_REGRESSION_GROUP_OF_BETAS_BATCH_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/linear_regression/linear_regression_group_of_betas_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace linear_regression
35 {
39 namespace quality_metric
40 {
44 namespace group_of_betas
45 {
46 namespace interface1
47 {
60 template<typename algorithmFPType, Method method, CpuType cpu>
61 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
62 {
63 public:
65  BatchContainer(daal::services::Environment::env *daalEnv);
67  virtual ~BatchContainer();
68 
74  virtual services::Status compute() DAAL_C11_OVERRIDE;
75 };
76 
89 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
90 class DAAL_EXPORT Batch : public daal::algorithms::quality_metric::Batch
91 {
92 public:
93  typedef algorithms::linear_regression::quality_metric::group_of_betas::Input InputType;
94  typedef algorithms::linear_regression::quality_metric::group_of_betas::Parameter ParameterType;
95  typedef algorithms::linear_regression::quality_metric::group_of_betas::Result ResultType;
96 
97  InputType input;
98  ParameterType parameter;
101  Batch(size_t nBeta, size_t nBetaReducedModel) : parameter(nBeta, nBetaReducedModel)
102  {
103  initialize();
104  }
105 
112  Batch(const Batch<algorithmFPType, method> &other): parameter(other.parameter)
113  {
114  initialize();
115  input.set(expectedResponses, other.input.get(expectedResponses));
116  input.set(predictedResponses, other.input.get(predictedResponses));
117  input.set(predictedReducedModelResponses, other.input.get(predictedReducedModelResponses));
118  }
119 
124  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
125 
130  ResultPtr getResult() const
131  {
132  return _result;
133  }
134 
141  services::Status setResult(const ResultPtr& result)
142  {
143  DAAL_CHECK(result, services::ErrorNullResult)
144  _result = result;
145  _res = _result.get();
146  return services::Status();
147  }
148 
153  virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
154  {
155  const InputType *inputPtr = static_cast<const InputType *>(other);
156  input.set(expectedResponses, inputPtr->get(expectedResponses));
157  input.set(predictedResponses, inputPtr->get(predictedResponses));
158  input.set(predictedReducedModelResponses, inputPtr->get(predictedReducedModelResponses));
159  }
160 
166  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
167  {
168  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
169  }
170 
171 protected:
172  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
173  {
174  return new Batch<algorithmFPType, method>(*this);
175  }
176 
177  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
178  {
179  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
180  _res = _result.get();
181  return s;
182  }
183 
184  virtual algorithms::ResultPtr getResultImpl() const DAAL_C11_OVERRIDE
185  {
186  return _result;
187  }
188 
189  void initialize()
190  {
191  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
192  _in = &input;
193  _par = &parameter;
194  _result.reset(new ResultType());
195  }
196 
197 private:
198  ResultPtr _result;
199 };
201 } // namespace interface1
202 using interface1::BatchContainer;
203 using interface1::Batch;
204 
205 }
206 }
207 }
208 }
209 }
210 #endif
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:90
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::getResult
ResultPtr getResult() const
Definition: linear_regression_group_of_betas_batch.h:130
daal::batch
Definition: daal_defines.h:112
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:166
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:61
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::parameter
ParameterType parameter
Definition: linear_regression_group_of_betas_batch.h:98
daal::algorithms::linear_regression::quality_metric::group_of_betas::predictedReducedModelResponses
Definition: linear_regression_group_of_betas_types.h:65
daal::services::ErrorNullResult
Definition: error_indexes.h:98
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:141
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::linear_regression::quality_metric::group_of_betas::predictedResponses
Definition: linear_regression_group_of_betas_types.h:64
daal::algorithms::linear_regression::quality_metric::group_of_betas::expectedResponses
Definition: linear_regression_group_of_betas_types.h:63
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::BatchContainer::~BatchContainer
virtual ~BatchContainer()
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:153
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:112
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:124
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::Batch::input
InputType input
Definition: linear_regression_group_of_betas_batch.h:97
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:101
daal::algorithms::linear_regression::quality_metric::group_of_betas::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70

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