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

lasso_regression_training_batch.h
1 /* file: lasso_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 lasso regression model-based training in the batch processing mode
19 //--
20 */
21 
22 #ifndef __LASSO_REGRESSION_TRAINING_BATCH_H__
23 #define __LASSO_REGRESSION_TRAINING_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "services/daal_defines.h"
27 #include "services/daal_memory.h"
28 #include "algorithms/lasso_regression/lasso_regression_training_types.h"
29 #include "algorithms/lasso_regression/lasso_regression_model.h"
30 #include "algorithms/linear_model/linear_model_training_batch.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace lasso_regression
37 {
38 namespace training
39 {
40 namespace interface1
41 {
51 template<typename algorithmFPType, Method method, CpuType cpu>
52 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
53 {
54 public:
59  BatchContainer(daal::services::Environment::env *daalEnv);
60 
62  ~BatchContainer();
63 
69  services::Status compute() DAAL_C11_OVERRIDE;
70 };
71 
87 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
88 class DAAL_EXPORT Batch : public linear_model::training::Batch
89 {
90 public:
91  typedef algorithms::lasso_regression::training::Input InputType;
92  typedef optimization_solver::iterative_solver::BatchPtr SolverPtr;
93  typedef algorithms::lasso_regression::training::Parameter ParameterType;
94  typedef algorithms::lasso_regression::training::Result ResultType;
95 
96  InputType input;
99  Batch(const SolverPtr& solver = SolverPtr());
100 
107  Batch(const Batch<algorithmFPType, method> &other);
108 
109  ~Batch()
110  {
111  delete _par;
112  }
113 
118  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
119 
124  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
125 
130  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
131 
136  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
137 
142  ResultPtr getResult() { return ResultType::cast(_result); }
143 
150  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
151  {
152  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
153  }
154 
155 protected:
156 
157  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
158  {
159  return new Batch<algorithmFPType, method>(*this);
160  }
161 
162  services::Status allocateResult() DAAL_C11_OVERRIDE
163  {
164  services::Status s = getResult()->template allocate<algorithmFPType>(&input, static_cast<const ParameterType*>(_par), method);
165  _res = _result.get();
166  return s;
167  }
168 
169  void initialize()
170  {
171  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
172  _in = &input;
173  _result.reset(new ResultType());
174  }
175 };
177 } // namespace interface1
178 
179 using interface1::BatchContainer;
180 using interface1::Batch;
181 
182 } // namespace training
183 } // namespace lasso_regression
184 } // namespace algorithms
185 } // namespace daal
186 
187 #endif
daal::algorithms::lasso_regression::training::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: lasso_regression_training_batch.h:124
daal
Definition: algorithm_base_common.h:31
daal::algorithms::lasso_regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: lasso_regression_training_batch.h:142
daal::algorithms::lasso_regression::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: lasso_regression_training_batch.h:150
daal::algorithms::lasso_regression::training::interface1::Batch::parameter
ParameterType & parameter()
Definition: lasso_regression_training_batch.h:118
daal_defines.h
daal::batch
Definition: daal_defines.h:110
daal::algorithms::lasso_regression::training::interface1::Batch::getInput
virtual regression::training::Input * getInput() DAAL_C11_OVERRIDE
Definition: lasso_regression_training_batch.h:130
daal::algorithms::lasso_regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: lasso_regression_training_batch.h:136
daal::algorithms::lasso_regression::training::interface1::Batch::input
InputType input
Definition: lasso_regression_training_batch.h:96
daal::algorithms::lasso_regression::training::interface1::BatchContainer
Class containing methods for normal equations lasso regression model-based training using algorithmFP...
Definition: lasso_regression_training_batch.h:52
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50
daal::algorithms::lasso_regression::training::interface1::Batch
Provides methods for lasso regression model-based training in the batch processing mode...
Definition: lasso_regression_training_batch.h:88

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