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

logistic_regression_training_batch.h
1 /* file: logistic_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 logistic regression model-based training
19 //--
20 */
21 
22 #ifndef __LOGISTIC_REGRESSION_TRAINING_BATCH_H__
23 #define __LOGISTIC_REGRESSION_TRAINING_BATCH_H__
24 
25 #include "algorithms/classifier/classifier_training_batch.h"
26 #include "algorithms/logistic_regression/logistic_regression_training_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace logistic_regression
33 {
34 namespace training
35 {
36 namespace interface1
37 {
51 template<typename algorithmFPType, Method method, CpuType cpu>
52 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
53 {
54 public:
60  BatchContainer(daal::services::Environment::env *daalEnv);
62  ~BatchContainer();
67  services::Status compute() DAAL_C11_OVERRIDE;
68  services::Status setupCompute() DAAL_C11_OVERRIDE;
69 };
70 
88 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
89 class DAAL_EXPORT Batch : public classifier::training::Batch
90 {
91 public:
92  typedef classifier::training::Batch super;
93  typedef optimization_solver::iterative_solver::BatchPtr SolverPtr;
94 
95  typedef typename super::InputType InputType;
96  typedef algorithms::logistic_regression::training::Parameter ParameterType;
97  typedef algorithms::logistic_regression::training::Result ResultType;
98 
99  InputType input;
106  Batch(size_t nClasses, const SolverPtr& solver = SolverPtr());
107 
114  Batch(const Batch<algorithmFPType, method> &other);
115 
117  ~Batch()
118  {
119  delete _par;
120  }
121 
126  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
127 
132  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
133 
138  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
139 
144  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
145 
150  ResultPtr getResult()
151  {
152  return ResultType::cast(_result);
153  }
154 
158  services::Status resetResult() DAAL_C11_OVERRIDE
159  {
160  _result.reset(new ResultType());
161  DAAL_CHECK(_result, services::ErrorNullResult);
162  _res = NULL;
163  return services::Status();
164  }
165 
171  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
172  {
173  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
174  }
175 
176 protected:
177  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
178  {
179  return new Batch<algorithmFPType, method>(*this);
180  }
181 
182  services::Status allocateResult() DAAL_C11_OVERRIDE
183  {
184  ResultPtr res = getResult();
185  DAAL_CHECK(res, services::ErrorNullResult);
186  services::Status s = res->template allocate<algorithmFPType>(&input, &parameter(), method);
187  _res = _result.get();
188  return s;
189  }
190 
191  void initialize()
192  {
193  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
194  _in = &input;
195  _result.reset(new ResultType());
196  }
197 };
199 } // namespace interface1
200 using interface1::BatchContainer;
201 using interface1::Batch;
202 
203 } // namespace daal::algorithms::logistic_regression::training
204 }
205 }
206 } // namespace daal
207 #endif // __LOGISTIC_REGRESSION_TRAINING_BATCH_H__
daal::algorithms::logistic_regression::training::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: logistic_regression_training_batch.h:132
daal
Definition: algorithm_base_common.h:31
daal::algorithms::logistic_regression::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: logistic_regression_training_batch.h:158
daal::algorithms::logistic_regression::training::interface1::Batch::~Batch
~Batch()
Definition: logistic_regression_training_batch.h:117
daal::algorithms::logistic_regression::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_regression_training_batch.h:171
daal::batch
Definition: daal_defines.h:110
daal::algorithms::logistic_regression::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: logistic_regression_training_batch.h:150
daal::algorithms::logistic_regression::training::interface1::Batch::input
InputType input
Definition: logistic_regression_training_batch.h:99
daal::algorithms::logistic_regression::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: logistic_regression_training_batch.h:138
daal::algorithms::logistic_regression::training::interface1::BatchContainer
Provides methods to run implementations of logistic regression model-based training. This class is associated with daal::algorithms::logistic_regression::training::Batch class.
Definition: logistic_regression_training_batch.h:52
daal::algorithms::logistic_regression::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_regression_training_batch.h:144
daal::algorithms::logistic_regression::training::interface1::Batch::parameter
ParameterType & parameter()
Definition: logistic_regression_training_batch.h:126
daal::algorithms::logistic_regression::training::interface1::Batch
Trains model of the logistic regression algorithms in the batch processing mode.
Definition: logistic_regression_training_batch.h:89
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:50

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