25 #ifndef __LINEAR_REGRESSION_TRAINING_DISTRIBUTED_H__
26 #define __LINEAR_REGRESSION_TRAINING_DISTRIBUTED_H__
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "services/daal_memory.h"
32 #include "algorithms/linear_regression/linear_regression_training_types.h"
33 #include "algorithms/linear_regression/linear_regression_training_online.h"
35 #include "algorithms/linear_regression/linear_regression_model.h"
41 namespace linear_regression
57 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
58 class DistributedContainer
66 template<
typename algorithmFPType, Method method, CpuType cpu>
67 class DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public
68 TrainingContainerIface<distributed>
76 DistributedContainer(daal::services::Environment::env *daalEnv);
78 ~DistributedContainer();
86 services::Status compute() DAAL_C11_OVERRIDE;
93 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
115 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = normEqDense>
116 class DAAL_EXPORT Distributed :
public Training<distributed> {};
137 template<
typename algorithmFPType, Method method>
138 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
141 typedef Online<algorithmFPType, method> super;
143 typedef typename super::InputType InputType;
144 typedef typename super::ParameterType ParameterType;
145 typedef typename super::ResultType ResultType;
146 typedef typename super::PartialResultType PartialResultType;
149 Distributed<step1Local, algorithmFPType, method>()
158 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
159 Online<algorithmFPType, method>(other)
168 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
170 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
174 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
176 return new Distributed<step1Local, algorithmFPType, method>(*this);
197 template<
typename algorithmFPType, Method method>
198 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public Training<distributed>
201 typedef algorithms::linear_regression::training::DistributedInput<step2Master> InputType;
202 typedef algorithms::linear_regression::Parameter ParameterType;
203 typedef algorithms::linear_regression::training::Result ResultType;
204 typedef algorithms::linear_regression::training::PartialResult PartialResultType;
218 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other)
221 input.set(partialModels, other.input.get(partialModels));
222 parameter = other.parameter;
231 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
239 services::Status setPartialResult(
const PartialResultPtr& partialResult)
241 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
242 _partialResult = partialResult;
243 _pres = _partialResult.get();
244 return services::Status();
251 PartialResultPtr getPartialResult() {
return _partialResult; }
259 services::Status setResult(
const ResultPtr& res)
261 DAAL_CHECK(res, services::ErrorNullResult)
263 _res = _result.get();
264 return services::Status();
273 ResultPtr getResult() {
return _result; }
281 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
283 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
286 DistributedInput<step2Master> input;
287 ParameterType parameter;
290 PartialResultPtr _partialResult;
293 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
295 return new Distributed<step2Master, algorithmFPType, method>(*this);
298 services::Status allocateResult() DAAL_C11_OVERRIDE
300 services::Status s = _result->allocate<algorithmFPType>(_pres, ¶meter, method);
301 _res = _result.get();
305 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
307 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, method);
308 _pres = _partialResult.get();
312 services::Status initializePartialResult() DAAL_C11_OVERRIDE
314 return services::Status();
319 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
322 _partialResult.reset(
new PartialResultType());
323 _result.reset(
new ResultType());
329 using interface1::DistributedContainer;
330 using interface1::Distributed;
daal::step1Local
Definition: daal_defines.h:123
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:281
daal::algorithms::linear_regression::training::interface1::DistributedInput< step2Master >
Input object for linear regression model-based training in the second step of the distributed process...
Definition: linear_regression_training_types.h:283
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: linear_regression_training_distributed.h:286
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: linear_regression_training_distributed.h:287
daal::step2Master
Definition: daal_defines.h:124
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:58
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:198
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: linear_regression_training_distributed.h:259
daal::algorithms::kmeans::init::interface2::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for K-Means algorithm in the distributed processing mode.
Definition: kmeans_init_distributed.h:277
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:168
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: linear_regression_training_distributed.h:207
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:116
daal::algorithms::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:62
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: linear_regression_training_distributed.h:218
daal::algorithms::linear_regression::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: linear_regression_training_distributed.h:158
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:138
daal::algorithms::linear_regression::training::interface1::DistributedInput< step2Master >::get
data_management::DataCollectionPtr get(Step2MasterInputId id) const
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:107
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:101
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: linear_regression_training_distributed.h:231
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: linear_regression_training_distributed.h:251
daal::distributed
Definition: daal_defines.h:113
daal::algorithms::linear_regression::training::partialModels
Definition: linear_regression_training_types.h:81
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: linear_regression_training_distributed.h:239
daal::algorithms::linear_regression::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: linear_regression_training_distributed.h:273