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

lasso_regression_training_batch.h
1 /* file: lasso_regression_training_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 // Implementation of the interface for lasso regression model-based training in the batch processing mode
21 //--
22 */
23 
24 #ifndef __LASSO_REGRESSION_TRAINING_BATCH_H__
25 #define __LASSO_REGRESSION_TRAINING_BATCH_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "services/daal_defines.h"
29 #include "services/daal_memory.h"
30 #include "algorithms/lasso_regression/lasso_regression_training_types.h"
31 #include "algorithms/lasso_regression/lasso_regression_model.h"
32 #include "algorithms/linear_model/linear_model_training_batch.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace lasso_regression
39 {
40 namespace training
41 {
42 namespace interface1
43 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class BatchContainer : public TrainingContainerIface<batch>
55 {
56 public:
61  BatchContainer(daal::services::Environment::env *daalEnv);
62 
64  ~BatchContainer();
65 
71  services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
89 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
90 class DAAL_EXPORT Batch : public linear_model::training::Batch
91 {
92 public:
93  typedef algorithms::lasso_regression::training::Input InputType;
94  typedef optimization_solver::iterative_solver::BatchPtr SolverPtr;
95  typedef algorithms::lasso_regression::training::Parameter ParameterType;
96  typedef algorithms::lasso_regression::training::Result ResultType;
97 
98  InputType input;
101  Batch(const SolverPtr& solver = SolverPtr());
102 
109  Batch(const Batch<algorithmFPType, method> &other);
110 
111  ~Batch()
112  {
113  delete _par;
114  }
115 
120  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
121 
126  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
127 
132  virtual regression::training::Input* getInput() DAAL_C11_OVERRIDE { return &input; }
133 
138  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
139 
144  ResultPtr getResult() { return ResultType::cast(_result); }
145 
149  services::Status resetResult() DAAL_C11_OVERRIDE
150  {
151  _result.reset(new ResultType());
152  DAAL_CHECK(_result, services::ErrorNullResult);
153  _res = NULL;
154  return services::Status();
155  }
156 
163  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
164  {
165  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
166  }
167 
168 protected:
169 
170  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
171  {
172  return new Batch<algorithmFPType, method>(*this);
173  }
174 
175  services::Status allocateResult() DAAL_C11_OVERRIDE
176  {
177  services::Status s = getResult()->template allocate<algorithmFPType>(&input, static_cast<const ParameterType*>(_par), method);
178  _res = _result.get();
179  return s;
180  }
181 
182  void initialize()
183  {
184  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
185  _in = &input;
186  _result.reset(new ResultType());
187  }
188 };
190 } // namespace interface1
191 
192 using interface1::BatchContainer;
193 using interface1::Batch;
194 
195 } // namespace training
196 } // namespace lasso_regression
197 } // namespace algorithms
198 } // namespace daal
199 
200 #endif
daal::algorithms::lasso_regression::training::interface1::Batch::parameter
ParameterType & parameter()
Definition: lasso_regression_training_batch.h:120
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:90
daal::algorithms::lasso_regression::training::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::batch
Definition: daal_defines.h:112
daal::algorithms::lasso_regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: lasso_regression_training_batch.h:138
daal::algorithms::lasso_regression::training::interface1::Batch::input
InputType input
Definition: lasso_regression_training_batch.h:98
daal::algorithms::lasso_regression::training::interface1::Batch::getInput
virtual regression::training::Input * getInput() DAAL_C11_OVERRIDE
Definition: lasso_regression_training_batch.h:132
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::lasso_regression::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: lasso_regression_training_batch.h:163
daal_defines.h
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:54
daal::algorithms::lasso_regression::training::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: lasso_regression_training_batch.h:126
daal::algorithms::lasso_regression::training::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::lasso_regression::training::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::lasso_regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: lasso_regression_training_batch.h:144
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::lasso_regression::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: lasso_regression_training_batch.h:149

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