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

multinomial_naive_bayes_predict.h
1 /* file: multinomial_naive_bayes_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 multinomial naive Bayes model-based prediction
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __NAIVE_BAYES_PREDICT_H__
26 #define __NAIVE_BAYES_PREDICT_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "multinomial_naive_bayes_predict_types.h"
32 #include "algorithms/classifier/classifier_predict.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace multinomial_naive_bayes
39 {
40 namespace prediction
41 {
42 
46 namespace interface1
47 {
60 template<typename algorithmFPType, prediction::Method method, CpuType cpu>
61 class BatchContainer : public PredictionContainerIface
62 {
63 public:
69  DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv);
71  DAAL_DEPRECATED ~BatchContainer();
77  DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
78 };
79 
91 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, prediction::Method method = defaultDense>
92 class Batch : public classifier::prediction::interface1::Batch
93 {
94 public:
95  typedef classifier::prediction::interface1::Batch super;
96 
97  typedef algorithms::multinomial_naive_bayes::prediction::Input InputType;
98  typedef algorithms::multinomial_naive_bayes::interface1::Parameter ParameterType;
99  typedef typename super::ResultType ResultType;
100 
101  InputType input;
102  ParameterType parameter;
107  DAAL_DEPRECATED Batch(size_t nClasses) : parameter(nClasses)
108  {
109  initialize();
110  }
111 
118  DAAL_DEPRECATED Batch(const Batch<algorithmFPType, method> &other) :
119  classifier::prediction::interface1::Batch(other), parameter(other.parameter), input(other.input)
120  {
121  initialize();
122  }
123 
124  DAAL_DEPRECATED_VIRTUAL virtual ~Batch() {}
125 
130  DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
131 
136  DAAL_DEPRECATED_VIRTUAL virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
137 
143  DAAL_DEPRECATED services::SharedPtr<Batch<algorithmFPType, method> > clone() const
144  {
145  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
146  }
147 
148 protected:
149 
150  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
151  {
152  return new Batch<algorithmFPType, method>(*this);
153  }
154 
155  services::Status allocateResult() DAAL_C11_OVERRIDE
156  {
157  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
158  _res = _result.get();
159  return s;
160  }
161 
162  void initialize()
163  {
164  _in = &input;
165  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, interface1::BatchContainer, algorithmFPType, method)(&_env);
166  _par = &parameter;
167  }
168 };
170 } // namespace interface1
171 
172 /*
173  * \brief Contains version 2.0 of the Intel(R) Data Analytics Acceleration Library (Intel(R) DAAL) interface
174  */
175 namespace interface2
176 {
189 template<typename algorithmFPType, prediction::Method method, CpuType cpu>
190 class BatchContainer : public PredictionContainerIface
191 {
192 public:
198  BatchContainer(daal::services::Environment::env *daalEnv);
200  ~BatchContainer();
206  services::Status compute() DAAL_C11_OVERRIDE;
207 };
208 
220 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, prediction::Method method = defaultDense>
221 class Batch : public classifier::prediction::Batch
222 {
223 public:
224  typedef classifier::prediction::Batch super;
225 
226  typedef algorithms::multinomial_naive_bayes::prediction::Input InputType;
227  typedef algorithms::multinomial_naive_bayes::Parameter ParameterType;
228  typedef typename super::ResultType ResultType;
229 
230  InputType input;
231  ParameterType parameter;
236  Batch(size_t nClasses) : parameter(nClasses)
237  {
238  initialize();
239  }
240 
247  Batch(const Batch<algorithmFPType, method> &other) :
248  classifier::prediction::Batch(other), parameter(other.parameter), input(other.input)
249  {
250  initialize();
251  }
252 
253  virtual ~Batch() {}
254 
259  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
260 
265  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
266 
272  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
273  {
274  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
275  }
276 
277 protected:
278 
279  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
280  {
281  return new Batch<algorithmFPType, method>(*this);
282  }
283 
284  services::Status allocateResult() DAAL_C11_OVERRIDE
285  {
286  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
287  _res = _result.get();
288  return s;
289  }
290 
291  void initialize()
292  {
293  _in = &input;
294  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
295  _par = &parameter;
296  }
297 };
299 } // namespace interface2
300 using interface2::BatchContainer;
301 using interface2::Batch;
302 
303 } // namespace prediction
304 } // namespace multinomial_naive_bayes
305 } // namespace algorithms
306 } // namespace daal
307 #endif
daal::algorithms::multinomial_naive_bayes::prediction::interface2::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_predict.h:265
daal::algorithms::multinomial_naive_bayes::prediction::interface2::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::multinomial_naive_bayes::prediction::interface2::Batch::Batch
Batch(size_t nClasses)
Definition: multinomial_naive_bayes_predict.h:236
daal::algorithms::multinomial_naive_bayes::prediction::interface2::Batch::input
InputType input
Definition: multinomial_naive_bayes_predict.h:230
daal::batch
Definition: daal_defines.h:112
daal::algorithms::multinomial_naive_bayes::prediction::interface1::BatchContainer::BatchContainer
DAAL_DEPRECATED BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::multinomial_naive_bayes::prediction::interface1::BatchContainer::compute
DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::multinomial_naive_bayes::prediction::interface2::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multinomial_naive_bayes_predict.h:272
daal::algorithms::multinomial_naive_bayes::prediction::interface2::Batch::parameter
ParameterType parameter
Definition: multinomial_naive_bayes_predict.h:231
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(const Batch< algorithmFPType, method > &other)
Definition: multinomial_naive_bayes_predict.h:118
daal::algorithms::multinomial_naive_bayes::prediction::interface2::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::multinomial_naive_bayes::prediction::interface2::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_predict.h:259
daal::algorithms::multinomial_naive_bayes::interface1::Parameter
Naive Bayes algorithm parameters.
Definition: multinomial_naive_bayes_model.h:60
daal::algorithms::classifier::prediction::interface1::Input
Input objects in the prediction stage of the classification algorithm.
Definition: classifier_predict_types.h:111
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch
Predicts the results of the multinomial naive Bayes classification.
Definition: multinomial_naive_bayes_predict.h:92
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::clone
DAAL_DEPRECATED services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multinomial_naive_bayes_predict.h:143
daal_defines.h
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::multinomial_naive_bayes::prediction::interface1::BatchContainer::~BatchContainer
DAAL_DEPRECATED ~BatchContainer()
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::multinomial_naive_bayes::prediction::interface1::Batch::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_predict.h:136
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: multinomial_naive_bayes_predict.h:102
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::Batch
DAAL_DEPRECATED Batch(size_t nClasses)
Definition: multinomial_naive_bayes_predict.h:107
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:69
daal::algorithms::multinomial_naive_bayes::prediction::interface2::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::multinomial_naive_bayes::prediction::interface2::Batch
Predicts the results of the multinomial naive Bayes classification.
Definition: multinomial_naive_bayes_predict.h:221
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::getInput
DAAL_DEPRECATED InputType * getInput() DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_predict.h:130
daal::algorithms::multinomial_naive_bayes::prediction::interface2::BatchContainer
Runs the prediction based on the multinomial naive Bayes model.
Definition: multinomial_naive_bayes_predict.h:190
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::input
InputType input
Definition: multinomial_naive_bayes_predict.h:101
daal::algorithms::multinomial_naive_bayes::prediction::interface1::BatchContainer
Runs the prediction based on the multinomial naive Bayes model.
Definition: multinomial_naive_bayes_predict.h:61
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::multinomial_naive_bayes::prediction::interface2::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: multinomial_naive_bayes_predict.h:247

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