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

logistic_regression_predict.h
1 /* file: logistic_regression_predict.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 prediction
19 //--
20 */
21 
22 #ifndef __LOGISTIC_REGRESSION_PREDICT_H__
23 #define __LOGISTIC_REGRESSION_PREDICT_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/classifier/classifier_predict.h"
27 #include "algorithms/logistic_regression/logistic_regression_model.h"
28 #include "algorithms/logistic_regression/logistic_regression_predict_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace logistic_regression
35 {
39 namespace prediction
40 {
50 namespace interface1
51 {
61 template<typename algorithmFPType, Method method, CpuType cpu>
62 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
63 {
64 public:
69  BatchContainer(daal::services::Environment::env *daalEnv);
71  ~BatchContainer();
76  services::Status compute() DAAL_C11_OVERRIDE;
77 };
78 
99 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
100 class DAAL_EXPORT Batch : public classifier::prediction::Batch
101 {
102 public:
103  typedef classifier::prediction::Batch super;
104 
105  typedef algorithms::logistic_regression::prediction::Input InputType;
106  typedef algorithms::logistic_regression::prediction::Parameter ParameterType;
107  typedef algorithms::logistic_regression::prediction::Result ResultType;
108 
113  Batch(size_t nClasses);
114 
121  Batch(const Batch<algorithmFPType, method> &other);
122 
124  ~Batch()
125  {
126  delete _par;
127  }
128 
133  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
134 
139  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
140 
145  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
146 
151  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
152 
158  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
159  {
160  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
161  }
162 
167  ResultPtr getResult() { return ResultType::cast(_result); }
168 
169 public:
170  InputType input;
172 protected:
173  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
174  {
175  return new Batch<algorithmFPType, method>(*this);
176  }
177 
178  services::Status allocateResult() DAAL_C11_OVERRIDE
179  {
180  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, _par, 0);
181  _res = _result.get();
182  return s;
183  }
184 
185  void initialize()
186  {
187  _in = &input;
188  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
189  _result.reset(new ResultType());
190  }
191 };
193 } // namespace interface1
194 using interface1::BatchContainer;
195 using interface1::Batch;
196 
197 } // namespace daal::algorithms::logistic_regression::prediction
198 }
199 }
200 } // namespace daal
201 #endif
daal::algorithms::logistic_regression::prediction::interface1::Batch::parameter
ParameterType & parameter()
Definition: logistic_regression_predict.h:133
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:62
daal
Definition: algorithm_base_common.h:31
daal::algorithms::logistic_regression::prediction::interface1::Batch::input
InputType input
Definition: logistic_regression_predict.h:170
daal::algorithms::logistic_regression::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: logistic_regression_predict.h:151
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:40
daal::algorithms::logistic_regression::prediction::interface1::Batch
Predicts logistic regression results.
Definition: logistic_regression_predict.h:100
daal::algorithms::logistic_regression::prediction::interface1::Batch::getResult
ResultPtr getResult()
Definition: logistic_regression_predict.h:167
daal::batch
Definition: daal_defines.h:110
daal::algorithms::logistic_regression::prediction::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: logistic_regression_predict.h:139
daal::algorithms::logistic_regression::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: logistic_regression_predict.h:158
daal::algorithms::logistic_regression::prediction::interface1::Batch::~Batch
~Batch()
Definition: logistic_regression_predict.h:124
daal::algorithms::classifier::prediction::prediction
Definition: classifier_predict_types.h:76
daal::algorithms::logistic_regression::prediction::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: logistic_regression_predict.h:145

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