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

multinomial_naive_bayes_training_batch.h
1 /* file: multinomial_naive_bayes_training_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 training
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __NAIVE_BAYES_TRAINING_BATCH_H__
24 #define __NAIVE_BAYES_TRAINING_BATCH_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_training_types.h"
30 #include "algorithms/classifier/classifier_training_batch.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
39 namespace multinomial_naive_bayes
40 {
41 namespace training
42 {
43 
44 namespace interface1
45 {
58 template<typename algorithmFPType, Method method, CpuType cpu>
59 class DAAL_EXPORT BatchContainer : public TrainingContainerIface<batch>
60 {
61 public:
67  BatchContainer(daal::services::Environment::env *daalEnv);
69  ~BatchContainer();
75  services::Status compute() DAAL_C11_OVERRIDE;
76 };
77 
90 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
91 class DAAL_EXPORT Batch : public classifier::training::Batch
92 {
93 public:
94  typedef classifier::training::Batch super;
95 
96  typedef typename super::InputType InputType;
97  typedef algorithms::multinomial_naive_bayes::Parameter ParameterType;
98  typedef algorithms::multinomial_naive_bayes::training::Result ResultType;
99 
100  ParameterType parameter;
101  InputType input;
107  Batch(size_t nClasses) : parameter(nClasses)
108  {
109  initialize();
110  }
111 
118  Batch(const Batch<algorithmFPType, method> &other) :
119  classifier::training::Batch(other), parameter(other.parameter), input(other.input)
120  {
121  initialize();
122  }
123 
124  virtual ~Batch() {}
125 
130  InputType * getInput() DAAL_C11_OVERRIDE { return &input; }
131 
136  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
137 
142  ResultPtr getResult()
143  {
144  return ResultType::cast(_result);
145  }
146 
150  services::Status resetResult() DAAL_C11_OVERRIDE
151  {
152  _result.reset(new ResultType());
153  DAAL_CHECK(_result, services::ErrorNullResult);
154  _res = NULL;
155  return services::Status();
156  }
157 
163  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
164  {
165  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
166  }
167 
168 protected:
169  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
170  {
171  return new Batch<algorithmFPType, method>(*this);
172  }
173 
174  services::Status allocateResult() DAAL_C11_OVERRIDE
175  {
176  ResultPtr res = getResult();
177  DAAL_CHECK(res, services::ErrorNullResult);
178  services::Status s = res->template allocate<algorithmFPType>(&input, &parameter, (int)method);
179  _res = _result.get();
180  return s;
181  }
182 
183  void initialize()
184  {
185  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
186  _in = &input;
187  _par = &parameter;
188  _result.reset(new ResultType());
189  }
190 };
192 } // namespace interface1
193 using interface1::BatchContainer;
194 using interface1::Batch;
195 
196 } // namespace training
197 } // namespace multinomial_naive_bayes
198 } // namespace algorithms
199 } //namespace daal
200 #endif
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multinomial_naive_bayes_training_batch.h:163
daal
Definition: algorithm_base_common.h:31
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::parameter
ParameterType parameter
Definition: multinomial_naive_bayes_training_batch.h:100
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: multinomial_naive_bayes_training_batch.h:118
daal_defines.h
daal::batch
Definition: daal_defines.h:106
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::getInput
InputType * getInput() DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_training_batch.h:130
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::getResult
ResultPtr getResult()
Definition: multinomial_naive_bayes_training_batch.h:142
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::resetResult
services::Status resetResult() DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_training_batch.h:150
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch
Algorithm class for training the naive Bayes model.
Definition: multinomial_naive_bayes_training_batch.h:91
daal::algorithms::multinomial_naive_bayes::training::interface1::BatchContainer
Class containing methods to compute naive Bayes training results.
Definition: multinomial_naive_bayes_training_batch.h:59
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_training_batch.h:136
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::input
InputType input
Definition: multinomial_naive_bayes_training_batch.h:101
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
daal::algorithms::multinomial_naive_bayes::training::interface1::Batch::Batch
Batch(size_t nClasses)
Definition: multinomial_naive_bayes_training_batch.h:107

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