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

logistic_regression_predict.h
1 /* file: logistic_regression_predict.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 logistic regression model-based prediction
21 //--
22 */
23 
24 #ifndef __LOGISTIC_REGRESSION_PREDICT_H__
25 #define __LOGISTIC_REGRESSION_PREDICT_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/classifier/classifier_predict.h"
29 #include "algorithms/logistic_regression/logistic_regression_model.h"
30 #include "algorithms/logistic_regression/logistic_regression_predict_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace logistic_regression
37 {
41 namespace prediction
42 {
52 namespace interface1
53 {
63 template<typename algorithmFPType, Method method, CpuType cpu>
64 class BatchContainer : public PredictionContainerIface
65 {
66 public:
71  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
73  DAAL_DEPRECATED ~BatchContainer();
78  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
79 };
80 
101 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
102 class DAAL_EXPORT Batch : public classifier::prediction::interface1::Batch
103 {
104 public:
105  typedef classifier::prediction::interface1::Batch super;
106 
107  typedef algorithms::logistic_regression::prediction::Input InputType;
108  typedef algorithms::logistic_regression::prediction::interface1::Parameter ParameterType;
109  typedef algorithms::logistic_regression::prediction::interface1::Result ResultType;
110 
115  DAAL_DEPRECATED Batch(size_t nClasses);
116 
123  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other);
124 
126  DAAL_DEPRECATED ~Batch()
127  {
128  delete _par;
129  }
130 
135  DAAL_DEPRECATED ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
136 
141  DAAL_DEPRECATED const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
142 
147  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
148 
153  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
154 
160  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
161  {
162  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
163  }
164 
169  DAAL_DEPRECATED interface1::ResultPtr getResult() { return ResultType::cast(_result); }
170 
171 public:
172  InputType input;
174 protected:
175  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
176  {
177  return new Batch<algorithmFPType, method>(*this);
178  }
179 
180  services::Status allocateResult() DAAL_C11_OVERRIDE
181  {
182  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, _par, 0);
183  _res = _result.get();
184  return s;
185  }
186 
187  void initialize()
188  {
189  _in = &input;
190  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
191  _result.reset(new ResultType());
192  }
193 };
195 } // namespace interface1
196 
200 namespace interface2
201 {
211 template<typename algorithmFPType, Method method, CpuType cpu>
212 class BatchContainer : public PredictionContainerIface
213 {
214 public:
219  BatchContainer(daal::services::Environment::env *daalEnv);
221  ~BatchContainer();
226  services::Status compute() DAAL_C11_OVERRIDE;
227 };
228 
249 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
250 class DAAL_EXPORT Batch : public classifier::prediction::Batch
251 {
252 public:
253  typedef classifier::prediction::Batch super;
254 
255  typedef algorithms::logistic_regression::prediction::Input InputType;
256  typedef algorithms::classifier::Parameter ParameterType;
257  typedef algorithms::classifier::prediction::Result ResultType;
258 
263  Batch(size_t nClasses);
264 
271  Batch(const Batch<algorithmFPType, method> &other);
272 
274  ~Batch()
275  {
276  delete _par;
277  }
278 
283  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
284 
289  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
290 
295  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
296 
301  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
302 
308  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
309  {
310  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
311  }
312 
317  classifier::prediction::ResultPtr getResult() { return ResultType::cast(_result); }
318 
319 public:
320  InputType input;
322 protected:
323  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
324  {
325  return new Batch<algorithmFPType, method>(*this);
326  }
327 
328  services::Status allocateResult() DAAL_C11_OVERRIDE
329  {
330  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, _par, 0);
331  _res = _result.get();
332  return s;
333  }
334 
335  void initialize()
336  {
337  _in = &input;
338  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, interface2::BatchContainer, algorithmFPType, method)(&_env);
339  _result.reset(new ResultType());
340  }
341 };
343 } // namespace interface2
344 using interface2::BatchContainer;
345 using interface2::Batch;
346 
347 } // namespace daal::algorithms::logistic_regression::prediction
348 }
349 }
350 } // namespace daal
351 #endif
daal::algorithms::logistic_regression::prediction::interface1::Batch::parameter
DAAL_DEPRECATED ParameterType & parameter()
Definition: logistic_regression_predict.h:135
daal::algorithms::logistic_regression::prediction::interface1::Parameter
Parameters of the prediction algorithm.
Definition: logistic_regression_predict_types.h:99
daal::algorithms::logistic_regression::prediction::interface2::Batch::getResult
classifier::prediction::ResultPtr getResult()
Definition: logistic_regression_predict.h:317
daal::algorithms::logistic_regression::prediction::interface2::Batch::parameter
const ParameterType & parameter() const
Definition: logistic_regression_predict.h:289
daal::batch
Definition: daal_defines.h:112
daal::algorithms::logistic_regression::prediction::interface1::Batch::getResult
DAAL_DEPRECATED interface1::ResultPtr getResult()
Definition: logistic_regression_predict.h:169
daal::algorithms::logistic_regression::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_regression_predict.h:301
daal::algorithms::logistic_regression::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: logistic_regression_predict.h:147
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::logistic_regression::prediction::interface2::Batch::input
InputType input
Definition: logistic_regression_predict.h:320
daal::algorithms::logistic_regression::prediction::interface2::Batch
Predicts logistic regression results.
Definition: logistic_regression_predict.h:250
daal::algorithms::logistic_regression::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: logistic_regression_predict.h:295
daal::algorithms::logistic_regression::prediction::interface2::Batch::parameter
ParameterType & parameter()
Definition: logistic_regression_predict.h:283
daal::algorithms::logistic_regression::prediction::interface1::BatchContainer
Provides methods to run implementations of the logistic regression algorithm. This class is associate...
Definition: logistic_regression_predict.h:64
daal::algorithms::logistic_regression::prediction::interface1::Batch
Predicts logistic regression results.
Definition: logistic_regression_predict.h:102
daal::algorithms::logistic_regression::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_regression_predict.h:160
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:111
daal::algorithms::logistic_regression::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_regression_predict.h:308
daal::algorithms::logistic_regression::prediction::interface1::Batch::~Batch
DAAL_DEPRECATED ~Batch()
Definition: logistic_regression_predict.h:126
daal::algorithms::logistic_regression::prediction::interface1::Batch::input
InputType input
Definition: logistic_regression_predict.h:172
daal::algorithms::logistic_regression::prediction::interface2::BatchContainer
Provides methods to run implementations of the logistic regression algorithm. This class is associate...
Definition: logistic_regression_predict.h:212
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::classifier::prediction::interface1::Result
Provides methods to access prediction results obtained with the compute() method of the classifier pr...
Definition: classifier_predict_types.h:168
daal::algorithms::logistic_regression::prediction::interface1::Batch::parameter
DAAL_DEPRECATED const ParameterType & parameter() const
Definition: logistic_regression_predict.h:141
daal::algorithms::logistic_regression::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
daal::algorithms::logistic_regression::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::logistic_regression::prediction::interface1::Result
Provides interface for the result of model-based prediction.
Definition: logistic_regression_predict_types.h:163
daal::algorithms::logistic_regression::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::logistic_regression::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::logistic_regression::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::logistic_regression::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::logistic_regression::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_regression_predict.h:153
daal::algorithms::classifier::prediction::interface1::Batch
Base class for making predictions based on the model of the classification algorithms.
Definition: classifier_predict.h:61
daal::algorithms::logistic_regression::prediction::interface2::Batch::~Batch
~Batch()
Definition: logistic_regression_predict.h:274

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