23 #ifndef __LINEAR_REGRESSION_TRAINING_DISTRIBUTED_H__
24 #define __LINEAR_REGRESSION_TRAINING_DISTRIBUTED_H__
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "services/daal_memory.h"
30 #include "algorithms/linear_regression/linear_regression_training_types.h"
31 #include "algorithms/linear_regression/linear_regression_training_online.h"
33 #include "algorithms/linear_regression/linear_regression_model.h"
39 namespace linear_regression
55 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
56 class DAAL_EXPORT DistributedContainer
64 template<
typename algorithmFPType, Method method, CpuType cpu>
65 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public
66 TrainingContainerIface<distributed>
74 DistributedContainer(daal::services::Environment::env *daalEnv);
76 ~DistributedContainer();
84 services::Status compute() DAAL_C11_OVERRIDE;
91 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
113 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
114 class DAAL_EXPORT Distributed :
public Training<distributed> {};
135 template<
typename algorithmFPType, Method method>
136 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
139 typedef Online<algorithmFPType, method> super;
141 typedef typename super::InputType InputType;
142 typedef typename super::ParameterType ParameterType;
143 typedef typename super::ResultType ResultType;
144 typedef typename super::PartialResultType PartialResultType;
147 Distributed<step1Local, algorithmFPType, method>()
156 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
157 Online<algorithmFPType, method>(other)
166 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
168 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
172 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
174 return new Distributed<step1Local, algorithmFPType, method>(*this);
195 template<
typename algorithmFPType, Method method>
196 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public Training<distributed>
199 typedef algorithms::linear_regression::training::DistributedInput<step2Master> InputType;
200 typedef algorithms::linear_regression::Parameter ParameterType;
201 typedef algorithms::linear_regression::training::Result ResultType;
202 typedef algorithms::linear_regression::training::PartialResult PartialResultType;
216 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other)
219 input.set(partialModels, other.input.get(partialModels));
220 parameter = other.parameter;
229 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
237 services::Status setPartialResult(
const PartialResultPtr& partialResult)
239 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
240 _partialResult = partialResult;
241 _pres = _partialResult.get();
242 return services::Status();
249 PartialResultPtr getPartialResult() {
return _partialResult; }
257 services::Status setResult(
const ResultPtr& res)
259 DAAL_CHECK(res, services::ErrorNullResult)
261 _res = _result.get();
262 return services::Status();
271 ResultPtr getResult() {
return _result; }
279 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
281 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
284 DistributedInput<step2Master> input;
285 ParameterType parameter;
288 PartialResultPtr _partialResult;
291 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
293 return new Distributed<step2Master, algorithmFPType, method>(*this);
296 services::Status allocateResult() DAAL_C11_OVERRIDE
298 services::Status s = _result->allocate<algorithmFPType>(_pres, ¶meter, method);
299 _res = _result.get();
303 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
305 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, method);
306 _pres = _partialResult.get();
310 services::Status initializePartialResult() DAAL_C11_OVERRIDE
312 return services::Status();
317 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
320 _partialResult.reset(
new PartialResultType());
321 _result.reset(
new ResultType());
327 using interface1::DistributedContainer;
328 using interface1::Distributed;
daal::algorithms::linear_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: linear_regression_training_distributed.h:166
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: linear_regression_training_distributed.h:285
daal
Definition: algorithm_base_common.h:31
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: linear_regression_training_distributed.h:216
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: linear_regression_training_distributed.h:279
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:105
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: linear_regression_training_distributed.h:205
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: linear_regression_training_distributed.h:249
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: linear_regression_training_distributed.h:257
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:255
daal::distributed
Definition: daal_defines.h:107
daal::algorithms::linear_regression::training::partialModels
Definition: linear_regression_training_types.h:79
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: linear_regression_training_distributed.h:271
daal::algorithms::linear_regression::training::interface1::Distributed
Provides methods for linear regression model-based training in the distributed processing mode...
Definition: linear_regression_training_distributed.h:114
daal::algorithms::linear_regression::training::interface1::DistributedContainer
Class containing methods for linear regression model-based training in the distributed processing mod...
Definition: linear_regression_training_distributed.h:56
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: linear_regression_training_distributed.h:237
daal::algorithms::linear_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: linear_regression_training_distributed.h:156
daal::algorithms::linear_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >
Performs linear regression model-based training in the the first step of the distributed processing m...
Definition: linear_regression_training_distributed.h:136
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: linear_regression_training_distributed.h:284
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >
Performs linear regression model-based training in the the second step of distributed processing mode...
Definition: linear_regression_training_distributed.h:196
daal::algorithms::kmeans::interface1::DistributedContainer
class DAAL_EXPORT DistributedContainer
Provides methods to run implementations of the K-Means algorithm. This class is associated with the d...
Definition: kmeans_distributed.h:55
daal::step1Local
Definition: daal_defines.h:117
daal::step2Master
Definition: daal_defines.h:118
daal::algorithms::linear_regression::training::interface1::Online
Provides methods for linear regression model-based training in the online processing mode...
Definition: linear_regression_training_online.h:99
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::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:60
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_distributed.h:229