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

implicit_als_predict_ratings_types.h
1 /* file: implicit_als_predict_ratings_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 classes used in the rating prediction stage
19 // of the implicit ALS algorithm
20 //--
21 */
22 
23 #ifndef __IMPLICIT_ALS_PREDICT_RATINGS_TYPES_H__
24 #define __IMPLICIT_ALS_PREDICT_RATINGS_TYPES_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "algorithms/implicit_als/implicit_als_model.h"
28 #include "data_management/data/homogen_numeric_table.h"
29 #include "data_management/data/csr_numeric_table.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace implicit_als
36 {
46 namespace prediction
47 {
51 namespace ratings
52 {
57 enum Method
58 {
59  defaultDense = 0,
60  allUsersAllItems = 0
61 };
62 
68 enum ModelInputId
69 {
70  model,
71  lastModelInputId = model
72 };
73 
79 enum PartialModelInputId
80 {
81  usersPartialModel,
83  itemsPartialModel,
85  lastPartialModelInputId = itemsPartialModel
86 };
87 
93 enum PartialResultId
94 {
95  finalResult,
96  lastPartialResultId = finalResult
97 };
98 
103 enum ResultId
104 {
105  prediction,
106  lastResultId = prediction
107 };
108 
112 namespace interface1
113 {
114 
119 class InputIface : public daal::algorithms::Input
120 {
121 public:
122  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
123  InputIface(const InputIface& other) : daal::algorithms::Input(other) {}
124  virtual ~InputIface() {}
125 
130  virtual size_t getNumberOfUsers() const = 0;
131 
136  virtual size_t getNumberOfItems() const = 0;
137 };
138 
143 class DAAL_EXPORT Input : public InputIface
144 {
145 public:
146  Input();
147  Input(const Input& other) : InputIface(other){}
148  virtual ~Input() {}
149 
155  ModelPtr get(ModelInputId id) const;
156 
162  void set(ModelInputId id, const ModelPtr &ptr);
163 
168  size_t getNumberOfUsers() const DAAL_C11_OVERRIDE;
169 
174  size_t getNumberOfItems() const DAAL_C11_OVERRIDE;
175 
181  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
182 };
183 
184 
190 template<ComputeStep step>
191 class DistributedInput
192 {};
193 
199 template<>
200 class DAAL_EXPORT DistributedInput<step1Local> : public InputIface
201 {
202 public:
203  DistributedInput();
204  DistributedInput(const DistributedInput& other) : InputIface(other){}
205 
206  virtual ~DistributedInput() {}
207 
213  PartialModelPtr get(PartialModelInputId id) const;
214 
220  void set(PartialModelInputId id, const PartialModelPtr &ptr);
221 
226  size_t getNumberOfUsers() const DAAL_C11_OVERRIDE;
227 
232  size_t getNumberOfItems() const DAAL_C11_OVERRIDE;
233 
239  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
240 };
241 
242 
248 class DAAL_EXPORT Result : public daal::algorithms::Result
249 {
250 public:
251  DECLARE_SERIALIZABLE_CAST(Result);
252  Result();
253  virtual ~Result()
254  {}
255 
261  data_management::NumericTablePtr get(ResultId id) const;
262 
268  void set(ResultId id, const data_management::NumericTablePtr &ptr);
269 
276  template <typename algorithmFPType>
277  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
278 
285  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
286 
287 protected:
289  template<typename Archive, bool onDeserialize>
290  services::Status serialImpl(Archive *arch)
291  {
292  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
293  }
294 };
295 typedef services::SharedPtr<Result> ResultPtr;
296 
301 class DAAL_EXPORT PartialResult : public daal::algorithms::PartialResult
302 {
303 public:
304  DECLARE_SERIALIZABLE_CAST(PartialResult);
306  PartialResult();
308  virtual ~PartialResult() {}
309 
316  template <typename algorithmFPType>
317  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
318 
324  ResultPtr get(PartialResultId id) const;
325 
331  void set(PartialResultId id, const ResultPtr &ptr);
332 
339  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
340 
341 protected:
343  template<typename Archive, bool onDeserialize>
344  services::Status serialImpl(Archive *arch)
345  {
346  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
347  }
348 };
349 typedef services::SharedPtr<PartialResult> PartialResultPtr;
350 
351 } // interface1
352 using interface1::InputIface;
353 using interface1::Input;
354 using interface1::DistributedInput;
355 using interface1::PartialResult;
356 using interface1::PartialResultPtr;
357 using interface1::Result;
358 using interface1::ResultPtr;
359 
360 }
361 }
363 }
364 }
365 }
366 
367 #endif
daal::algorithms::implicit_als::prediction::ratings::interface1::Input
Input objects for the rating prediction stage of the implicit ALS algorithm
Definition: implicit_als_predict_ratings_types.h:143
daal::algorithms::implicit_als::prediction::ratings::interface1::Result
Provides methods to access the prediction results obtained with the compute() method of the implicit ...
Definition: implicit_als_predict_ratings_types.h:248
daal
Definition: algorithm_base_common.h:31
daal::algorithms::implicit_als::prediction::ratings::Method
Method
Definition: implicit_als_predict_ratings_types.h:57
daal::algorithms::interface1::Result
Base class to represent final results of the computation. Algorithm-specific final results are repres...
Definition: algorithm_types.h:307
daal::algorithms::implicit_als::prediction::ratings::itemsPartialModel
Definition: implicit_als_predict_ratings_types.h:83
daal::algorithms::implicit_als::prediction::ratings::PartialResultId
PartialResultId
Definition: implicit_als_predict_ratings_types.h:93
daal::algorithms::interface1::PartialResult
Base class to represent partial results of the computation. Algorithm-specific partial results are re...
Definition: algorithm_types.h:227
daal::algorithms::implicit_als::prediction::ratings::allUsersAllItems
Definition: implicit_als_predict_ratings_types.h:60
daal::algorithms::implicit_als::prediction::ratings::PartialModelInputId
PartialModelInputId
Definition: implicit_als_predict_ratings_types.h:79
daal::algorithms::implicit_als::prediction::ratings::interface1::PartialResult::~PartialResult
virtual ~PartialResult()
Definition: implicit_als_predict_ratings_types.h:308
daal::algorithms::implicit_als::prediction::ratings::usersPartialModel
Definition: implicit_als_predict_ratings_types.h:81
daal::algorithms::implicit_als::prediction::ratings::defaultDense
Definition: implicit_als_predict_ratings_types.h:59
daal::algorithms::implicit_als::prediction::ratings::ModelInputId
ModelInputId
Definition: implicit_als_predict_ratings_types.h:68
daal::algorithms::implicit_als::prediction::ratings::prediction
Definition: implicit_als_predict_ratings_types.h:105
daal::algorithms::implicit_als::prediction::ratings::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the implicit ALS ini...
Definition: implicit_als_predict_ratings_types.h:301
daal::algorithms::implicit_als::prediction::ratings::interface1::DistributedInput
Input objects for the rating prediction stage of the implicit ALS algorithm in the distributed proces...
Definition: implicit_als_predict_ratings_types.h:191
daal::algorithms::implicit_als::prediction::ratings::model
Definition: implicit_als_predict_ratings_types.h:70
daal::algorithms::implicit_als::prediction::ratings::interface1::InputIface::getNumberOfItems
virtual size_t getNumberOfItems() const =0
daal::algorithms::implicit_als::prediction::ratings::ResultId
ResultId
Definition: implicit_als_predict_ratings_types.h:103
daal::algorithms::implicit_als::prediction::ratings::interface1::InputIface
Input interface for the rating prediction stage of the implicit ALS algorithm
Definition: implicit_als_predict_ratings_types.h:119
daal::step1Local
Definition: daal_defines.h:117
daal::algorithms::implicit_als::prediction::ratings::interface1::InputIface::getNumberOfUsers
virtual size_t getNumberOfUsers() const =0
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:191
daal::algorithms::implicit_als::prediction::ratings::finalResult
Definition: implicit_als_predict_ratings_types.h:95

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