C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

kmeans_types.h
1 /* file: kmeans_types.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 K-Means algorithm interface.
19 //--
20 */
21 
22 #ifndef __KMEANS_TYPES_H__
23 #define __KMEANS_TYPES_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/numeric_table.h"
27 #include "data_management/data/homogen_numeric_table.h"
28 #include "services/daal_defines.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
41 namespace kmeans
42 {
47 enum Method
48 {
49  lloydDense = 0,
50  defaultDense = 0,
51  lloydCSR = 1
52 };
53 
58 enum DistanceType
59 {
60  euclidean,
61  lastDistanceType = euclidean
62 };
63 
68 enum InputId
69 {
70  data,
71  inputCentroids,
72  lastInputId = inputCentroids
73 };
74 
79 enum MasterInputId
80 {
81  partialResults,
82  lastMasterInputId = partialResults
83 };
84 
89 enum PartialResultId
90 {
91  nObservations,
92  partialSums,
93  partialObjectiveFunction,
94  partialGoalFunction = partialObjectiveFunction,
95  partialAssignments,
96  partialCandidatesDistances,
97  partialCandidatesCentroids,
98  lastPartialResultId = partialCandidatesCentroids
99 };
100 
105 enum ResultId
106 {
107  centroids,
108  assignments,
109  objectiveFunction,
110  goalFunction = objectiveFunction,
111  nIterations,
112  lastResultId = nIterations
113 };
114 
118 namespace interface1
119 {
128 /* [Parameter source code] */
129 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
130 {
136  Parameter(size_t _nClusters, size_t _maxIterations);
137 
142  Parameter(const Parameter &other);
143 
144  size_t nClusters;
145  size_t maxIterations;
146  double accuracyThreshold;
147  double gamma;
148  DistanceType distanceType;
149  bool assignFlag;
151  services::Status check() const DAAL_C11_OVERRIDE;
152 };
153 /* [Parameter source code] */
154 
159 class DAAL_EXPORT InputIface : public daal::algorithms::Input
160 {
161 public:
162  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {};
163 
164  virtual size_t getNumberOfFeatures() const = 0;
165 };
166 
171 class DAAL_EXPORT Input : public InputIface
172 {
173 public:
174  Input();
175  virtual ~Input() {}
176 
182  data_management::NumericTablePtr get(InputId id) const;
183 
189  void set(InputId id, const data_management::NumericTablePtr &ptr);
190 
191 
196  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
197 
203  services::Status check(const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
204 };
205 
210 class DAAL_EXPORT PartialResult : public daal::algorithms::PartialResult
211 {
212 public:
213  DECLARE_SERIALIZABLE_CAST(PartialResult);
214  PartialResult();
215 
216  virtual ~PartialResult() {};
217 
224  template <typename algorithmFPType>
225  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
226 
232  data_management::NumericTablePtr get(PartialResultId id) const;
233 
239  void set(PartialResultId id, const data_management::NumericTablePtr &ptr);
240 
246  size_t getNumberOfFeatures() const;
247 
254  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
255 
261  services::Status check(const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
262 
263 protected:
265  template<typename Archive, bool onDeserialize>
266  services::Status serialImpl(Archive *arch)
267  {
268  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
269  }
270 };
271 typedef services::SharedPtr<PartialResult> PartialResultPtr;
272 
277 class DAAL_EXPORT Result : public daal::algorithms::Result
278 {
279 public:
280  DECLARE_SERIALIZABLE_CAST(Result);
281  Result();
282 
283  virtual ~Result() {};
284 
291  template <typename algorithmFPType>
292  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
293 
300  template <typename algorithmFPType>
301  DAAL_EXPORT services::Status allocate(const daal::algorithms::PartialResult *partialResult, const daal::algorithms::Parameter *parameter, const int method);
302 
308  data_management::NumericTablePtr get(ResultId id) const;
309 
315  void set(ResultId id, const data_management::NumericTablePtr &ptr);
316 
323  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
324 
331  services::Status check(const daal::algorithms::PartialResult *pres, const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
332 
333 protected:
335  template<typename Archive, bool onDeserialize>
336  services::Status serialImpl(Archive *arch)
337  {
338  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
339  }
340 };
341 typedef services::SharedPtr<Result> ResultPtr;
342 
347 class DAAL_EXPORT DistributedStep2MasterInput : public InputIface
348 {
349 public:
350  DistributedStep2MasterInput();
351 
352  virtual ~DistributedStep2MasterInput() {}
353 
359  data_management::DataCollectionPtr get(MasterInputId id) const;
360 
366  void set(MasterInputId id, const data_management::DataCollectionPtr &ptr);
367 
374  void add(MasterInputId id, const PartialResultPtr &value);
375 
381  size_t getNumberOfFeatures() const DAAL_C11_OVERRIDE;
382 
388  services::Status check(const daal::algorithms::Parameter *par, int method) const DAAL_C11_OVERRIDE;
389 };
390 } // namespace interface1
391 using interface1::Parameter;
392 using interface1::InputIface;
393 using interface1::Input;
394 using interface1::PartialResult;
395 using interface1::PartialResultPtr;
396 using interface1::Result;
397 using interface1::ResultPtr;
398 using interface1::DistributedStep2MasterInput;
399 
400 } // namespace daal::algorithms::kmeans
402 } // namespace daal::algorithms
403 } // namespace daal
404 #endif
daal::algorithms::kmeans::partialAssignments
Definition: kmeans_types.h:95
daal::algorithms::kmeans::interface1::Parameter
Parameters for the K-Means algorithm.
Definition: kmeans_types.h:129
daal::algorithms::kmeans::interface1::Result
Results obtained with the compute() method of the K-Means algorithm in the batch processing mode...
Definition: kmeans_types.h:277
daal
Definition: algorithm_base_common.h:31
daal::algorithms::kmeans::interface1::Parameter::assignFlag
bool assignFlag
Definition: kmeans_types.h:149
daal::algorithms::kmeans::interface1::InputIface
Interface for input objects for the the K-Means algorithm in the batch and distributed processing mod...
Definition: kmeans_types.h:159
daal::algorithms::kmeans::interface1::PartialResult
Partial results obtained with the compute() method of the K-Means algorithm in the batch processing m...
Definition: kmeans_types.h:210
daal::algorithms::kmeans::lloydCSR
Definition: kmeans_types.h:51
daal::algorithms::kmeans::MasterInputId
MasterInputId
Available identifiers of input objects for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_types.h:79
daal::algorithms::kmeans::PartialResultId
PartialResultId
Available identifiers of partial results of the K-Means algorithm in the distributed processing mode...
Definition: kmeans_types.h:89
daal::algorithms::kmeans::assignments
Definition: kmeans_types.h:108
daal::algorithms::kmeans::interface1::Parameter::accuracyThreshold
double accuracyThreshold
Definition: kmeans_types.h:146
daal::algorithms::kmeans::nIterations
Definition: kmeans_types.h:111
daal::algorithms::kmeans::interface1::Parameter::nClusters
size_t nClusters
Definition: kmeans_types.h:144
daal::algorithms::kmeans::interface1::Parameter::gamma
double gamma
Definition: kmeans_types.h:147
daal::algorithms::kmeans::inputCentroids
Definition: kmeans_types.h:71
daal::algorithms::kmeans::partialObjectiveFunction
Definition: kmeans_types.h:93
daal::algorithms::kmeans::interface1::DistributedStep2MasterInput
Input objects for the K-Means algorithm in the distributed processing mode
Definition: kmeans_types.h:347
daal::algorithms::kmeans::interface1::Input
Input objects for the K-Means algorithm
Definition: kmeans_types.h:171
daal_defines.h
daal::algorithms::kmeans::lloydDense
Definition: kmeans_types.h:49
daal::algorithms::kmeans::data
Definition: kmeans_types.h:70
daal::algorithms::kmeans::defaultDense
Definition: kmeans_types.h:50
daal::algorithms::kmeans::InputId
InputId
Available identifiers of input objects for the K-Means algorithm.
Definition: kmeans_types.h:68
daal::algorithms::kmeans::nObservations
Definition: kmeans_types.h:91
daal::algorithms::kmeans::ResultId
ResultId
Available identifiers of results of the K-Means algorithm.
Definition: kmeans_types.h:105
daal::algorithms::kmeans::goalFunction
Definition: kmeans_types.h:110
daal::algorithms::kmeans::partialGoalFunction
Definition: kmeans_types.h:94
daal::algorithms::kmeans::interface1::Parameter::maxIterations
size_t maxIterations
Definition: kmeans_types.h:145
daal::algorithms::kmeans::partialCandidatesCentroids
Definition: kmeans_types.h:97
daal::algorithms::kmeans::DistanceType
DistanceType
Definition: kmeans_types.h:58
daal::algorithms::kmeans::partialResults
Definition: kmeans_types.h:81
daal::algorithms::kmeans::partialCandidatesDistances
Definition: kmeans_types.h:96
daal::algorithms::math::abs::value
Definition: abs_types.h:86
daal::algorithms::kmeans::Method
Method
Definition: kmeans_types.h:47
daal::algorithms::kmeans::euclidean
Definition: kmeans_types.h:60
daal::algorithms::kmeans::partialSums
Definition: kmeans_types.h:92
daal::algorithms::kmeans::objectiveFunction
Definition: kmeans_types.h:109
daal::algorithms::kmeans::interface1::Parameter::distanceType
DistanceType distanceType
Definition: kmeans_types.h:148
daal::algorithms::kmeans::centroids
Definition: kmeans_types.h:107

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