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

multinomial_naive_bayes_predict.h
1 /* file: multinomial_naive_bayes_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 multinomial naive Bayes model-based prediction
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __NAIVE_BAYES_PREDICT_H__
24 #define __NAIVE_BAYES_PREDICT_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "multinomial_naive_bayes_predict_types.h"
30 #include "algorithms/classifier/classifier_predict.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace multinomial_naive_bayes
37 {
38 namespace prediction
39 {
40 
44 namespace interface1
45 {
58 template<typename algorithmFPType, prediction::Method method, CpuType cpu>
59 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
60 {
61 public:
67  BatchContainer(daal::services::Environment::env *daalEnv);
69  ~BatchContainer();
75  services::Status compute() DAAL_C11_OVERRIDE;
76 };
77 
89 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, prediction::Method method = defaultDense>
90 class Batch : public classifier::prediction::Batch
91 {
92 public:
93  typedef classifier::prediction::Batch super;
94 
95  typedef algorithms::multinomial_naive_bayes::prediction::Input InputType;
96  typedef algorithms::multinomial_naive_bayes::Parameter ParameterType;
97  typedef typename super::ResultType ResultType;
98 
99  InputType input;
100  ParameterType parameter;
105  Batch(size_t nClasses) : parameter(nClasses)
106  {
107  initialize();
108  }
109 
116  Batch(const Batch<algorithmFPType, method> &other) :
117  classifier::prediction::Batch(other), parameter(other.parameter), input(other.input)
118  {
119  initialize();
120  }
121 
122  virtual ~Batch() {}
123 
128  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
129 
134  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
135 
141  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
142  {
143  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
144  }
145 
146 protected:
147 
148  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
149  {
150  return new Batch<algorithmFPType, method>(*this);
151  }
152 
153  services::Status allocateResult() DAAL_C11_OVERRIDE
154  {
155  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
156  _res = _result.get();
157  return s;
158  }
159 
160  void initialize()
161  {
162  _in = &input;
163  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
164  _par = &parameter;
165  }
166 };
168 } // namespace interface1
169 using interface1::BatchContainer;
170 using interface1::Batch;
171 
172 } // namespace prediction
173 } // namespace multinomial_naive_bayes
174 } // namespace algorithms
175 } // namespace daal
176 #endif
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: multinomial_naive_bayes_predict.h:105
daal
Definition: algorithm_base_common.h:31
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::parameter
ParameterType parameter
Definition: multinomial_naive_bayes_predict.h:100
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:40
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multinomial_naive_bayes_predict.h:141
daal_defines.h
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch
Predicts the results of the multinomial naive Bayes classification.
Definition: multinomial_naive_bayes_predict.h:90
daal::algorithms::multinomial_naive_bayes::prediction::interface1::BatchContainer
Runs the prediction based on the multinomial naive Bayes model.
Definition: multinomial_naive_bayes_predict.h:59
daal::batch
Definition: daal_defines.h:110
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: multinomial_naive_bayes_predict.h:116
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_predict.h:134
daal::algorithms::classifier::prediction::prediction
Definition: classifier_predict_types.h:76
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::input
InputType input
Definition: multinomial_naive_bayes_predict.h:99
daal::algorithms::multinomial_naive_bayes::prediction::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_predict.h:128

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