49 #ifndef __NAIVE_BAYES_TRAINING_DISTRIBUTED_H__ 50 #define __NAIVE_BAYES_TRAINING_DISTRIBUTED_H__ 52 #include "algorithms/algorithm.h" 53 #include "multinomial_naive_bayes_training_types.h" 59 namespace multinomial_naive_bayes
79 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
80 class DAAL_EXPORT DistributedContainer;
86 template<
typename algorithmFPType, Method method, CpuType cpu>
87 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public TrainingContainerIface<distributed>
95 DistributedContainer(daal::services::Environment::env *daalEnv);
97 ~DistributedContainer();
105 services::Status compute() DAAL_C11_OVERRIDE;
112 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
127 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
128 class DAAL_EXPORT Distributed {};
143 template<
typename algorithmFPType, Method method>
144 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
147 typedef Online<algorithmFPType, method> super;
149 typedef typename super::InputType InputType;
150 typedef typename super::ParameterType ParameterType;
151 typedef typename super::ResultType ResultType;
152 typedef typename super::PartialResultType PartialResultType;
158 Distributed(
size_t nClasses) : Online<algorithmFPType, method>::Online(nClasses) {}
166 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
167 Online<algorithmFPType, method>(other)
175 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const 177 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
181 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
183 return new Distributed<step1Local, algorithmFPType, method>(*this);
200 template<
typename algorithmFPType, Method method>
201 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public Training<distributed>
204 typedef algorithms::multinomial_naive_bayes::training::DistributedInput InputType;
205 typedef algorithms::multinomial_naive_bayes::Parameter ParameterType;
206 typedef algorithms::multinomial_naive_bayes::training::Result ResultType;
207 typedef algorithms::multinomial_naive_bayes::training::PartialResult PartialResultType;
209 ParameterType parameter;
216 Distributed(
size_t nClasses) : parameter(nClasses)
227 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) :
228 Training<distributed>(other), input(other.input), parameter(other.parameter)
233 virtual ~Distributed() {}
239 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
245 services::Status setPartialResult(
const PartialResultPtr& partialResult)
247 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
248 _partialResult = partialResult;
249 _pres = _partialResult.get();
250 return services::Status();
257 PartialResultPtr getPartialResult() {
return _partialResult; }
265 services::Status setResult(
const ResultPtr& result)
267 DAAL_CHECK(result, services::ErrorNullResult)
269 _res = _result.get();
270 return services::Status();
277 ResultPtr getResult()
279 return ResultType::cast(_result);
287 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
289 PartialResultPtr partialResult = getPartialResult();
290 DAAL_CHECK(partialResult, services::ErrorNullResult);
292 DAAL_CHECK_STATUS(s, partialResult->check(_par, method));
293 ResultPtr result = getResult();
294 DAAL_CHECK(result, services::ErrorNullResult);
295 DAAL_CHECK_STATUS(s, result->check(_pres, _par, method));
304 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const 306 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
310 PartialResultPtr _partialResult;
313 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
315 return new Distributed<step2Master, algorithmFPType, method>(*this);
318 services::Status allocateResult() DAAL_C11_OVERRIDE
320 PartialResultPtr pres = getPartialResult();
321 ResultPtr res = getResult();
322 services::Status s = res->template allocate<algorithmFPType>(pres.get(), ¶meter, (int)method);
323 _res = _result.get();
327 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
329 PartialResultPtr pres = getPartialResult();
330 services::Status s = pres->template allocate<algorithmFPType>((classifier::training::InputIface *)(&input), ¶meter, (int)method);
331 _pres = _partialResult.get();
335 services::Status initializePartialResult() DAAL_C11_OVERRIDE
337 return services::Status();
342 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
345 _result.reset(
new ResultType());
346 _partialResult.reset(
new PartialResultType());
351 using interface1::DistributedContainer;
352 using interface1::Distributed;
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &result)
Definition: multinomial_naive_bayes_training_distributed.h:265
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: multinomial_naive_bayes_training_distributed.h:257
daal::algorithms::classifier::interface1::Parameter
Base class for the parameters of the classification algorithm.
Definition: classifier_model.h:81
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step1Local, algorithmFPType, method >
Algorithm class for training Naive Bayes partial model in the distributed processing mode...
Definition: multinomial_naive_bayes_training_distributed.h:144
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: multinomial_naive_bayes_training_distributed.h:245
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: multinomial_naive_bayes_training_distributed.h:277
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(size_t nClasses)
Definition: multinomial_naive_bayes_training_distributed.h:158
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_training_distributed.h:239
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: multinomial_naive_bayes_training_distributed.h:304
daal::algorithms::kmeans::init::interface1::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_init_distributed.h:281
daal::distributed
Definition: daal_defines.h:133
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::multinomial_naive_bayes::training::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the naive Bayes trai...
Definition: multinomial_naive_bayes_training_types.h:104
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(size_t nClasses)
Definition: multinomial_naive_bayes_training_distributed.h:216
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >
Algorithm class for training naive Bayes final model on the second step in the distributed processing...
Definition: multinomial_naive_bayes_training_distributed.h:201
daal::services::interface1::SharedPtr::reset
void reset()
Definition: daal_shared_ptr.h:265
daal::algorithms::multinomial_naive_bayes::training::interface1::Result
Provides methods to access final results obtained with the compute() method of the naive Bayes traini...
Definition: multinomial_naive_bayes_training_types.h:185
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: multinomial_naive_bayes_training_distributed.h:227
daal::algorithms::multinomial_naive_bayes::training::interface1::DistributedContainer
class DAAL_EXPORT DistributedContainer
Class containing methods to compute naive Bayes training results in the distributed processing mode...
Definition: multinomial_naive_bayes_training_distributed.h:80
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: multinomial_naive_bayes_training_distributed.h:175
daal::algorithms::classifier::training::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the classifier train...
Definition: classifier_training_types.h:175
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: multinomial_naive_bayes_training_distributed.h:166
daal::algorithms::multinomial_naive_bayes::interface1::Parameter
Naive Bayes algorithm parameters.
Definition: multinomial_naive_bayes_model.h:84
daal::algorithms::classifier::training::interface1::Result
Provides methods to access final results obtained with the compute() method in the batch processing m...
Definition: classifier_training_types.h:222
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: multinomial_naive_bayes_training_distributed.h:209
daal::step1Local
Definition: daal_defines.h:143
daal::step2Master
Definition: daal_defines.h:144
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed
Algorithm class for training naive Bayes model in the distributed processing mode.
Definition: multinomial_naive_bayes_training_distributed.h:128
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
InputType input
Definition: multinomial_naive_bayes_training_distributed.h:210
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:76
daal::algorithms::multinomial_naive_bayes::training::interface1::Online
Algorithm class for training naive Bayes model.
Definition: multinomial_naive_bayes_training_online.h:122
daal::algorithms::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:86
daal::algorithms::multinomial_naive_bayes::training::interface1::Distributed< step2Master, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: multinomial_naive_bayes_training_distributed.h:287