C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

implicit_als_predict_ratings_types.h
1 /* file: implicit_als_predict_ratings_types.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the classes used in the rating prediction stage
21 // of the implicit ALS algorithm
22 //--
23 */
24 
25 #ifndef __IMPLICIT_ALS_PREDICT_RATINGS_TYPES_H__
26 #define __IMPLICIT_ALS_PREDICT_RATINGS_TYPES_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "algorithms/implicit_als/implicit_als_model.h"
30 #include "data_management/data/homogen_numeric_table.h"
31 #include "data_management/data/csr_numeric_table.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace implicit_als
38 {
48 namespace prediction
49 {
53 namespace ratings
54 {
59 enum Method
60 {
61  defaultDense = 0,
62  allUsersAllItems = 0
63 };
64 
70 enum ModelInputId
71 {
72  model,
73  lastModelInputId = model
74 };
75 
81 enum PartialModelInputId
82 {
83  usersPartialModel,
85  itemsPartialModel,
87  lastPartialModelInputId = itemsPartialModel
88 };
89 
95 enum PartialResultId
96 {
97  finalResult,
98  lastPartialResultId = finalResult
99 };
100 
105 enum ResultId
106 {
107  prediction,
108  lastResultId = prediction
109 };
110 
114 namespace interface1
115 {
116 
121 class InputIface : public daal::algorithms::Input
122 {
123 public:
124  InputIface(size_t nElements) : daal::algorithms::Input(nElements) {}
125  InputIface(const InputIface& other) : daal::algorithms::Input(other) {}
126  virtual ~InputIface() {}
127 
132  virtual size_t getNumberOfUsers() const = 0;
133 
138  virtual size_t getNumberOfItems() const = 0;
139 };
140 
145 class DAAL_EXPORT Input : public InputIface
146 {
147 public:
148  Input();
149  Input(const Input& other) : InputIface(other){}
150  virtual ~Input() {}
151 
157  ModelPtr get(ModelInputId id) const;
158 
164  void set(ModelInputId id, const ModelPtr &ptr);
165 
170  size_t getNumberOfUsers() const DAAL_C11_OVERRIDE;
171 
176  size_t getNumberOfItems() const DAAL_C11_OVERRIDE;
177 
183  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
184 };
185 
186 
192 template<ComputeStep step>
193 class DistributedInput
194 {};
195 
201 template<>
202 class DAAL_EXPORT DistributedInput<step1Local> : public InputIface
203 {
204 public:
205  DistributedInput();
206  DistributedInput(const DistributedInput& other) : InputIface(other){}
207 
208  virtual ~DistributedInput() {}
209 
215  PartialModelPtr get(PartialModelInputId id) const;
216 
222  void set(PartialModelInputId id, const PartialModelPtr &ptr);
223 
228  size_t getNumberOfUsers() const DAAL_C11_OVERRIDE;
229 
234  size_t getNumberOfItems() const DAAL_C11_OVERRIDE;
235 
241  services::Status check(const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
242 };
243 
244 
250 class DAAL_EXPORT Result : public daal::algorithms::Result
251 {
252 public:
253  DECLARE_SERIALIZABLE_CAST(Result);
254  Result();
255  virtual ~Result()
256  {}
257 
263  data_management::NumericTablePtr get(ResultId id) const;
264 
270  void set(ResultId id, const data_management::NumericTablePtr &ptr);
271 
278  template <typename algorithmFPType>
279  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
280 
287  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
288 
289 protected:
291  template<typename Archive, bool onDeserialize>
292  services::Status serialImpl(Archive *arch)
293  {
294  return daal::algorithms::Result::serialImpl<Archive, onDeserialize>(arch);
295  }
296 };
297 typedef services::SharedPtr<Result> ResultPtr;
298 
303 class DAAL_EXPORT PartialResult : public daal::algorithms::PartialResult
304 {
305 public:
306  DECLARE_SERIALIZABLE_CAST(PartialResult);
308  PartialResult();
310  virtual ~PartialResult() {}
311 
318  template <typename algorithmFPType>
319  DAAL_EXPORT services::Status allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method);
320 
326  ResultPtr get(PartialResultId id) const;
327 
333  void set(PartialResultId id, const ResultPtr &ptr);
334 
341  services::Status check(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, int method) const DAAL_C11_OVERRIDE;
342 
343 protected:
345  template<typename Archive, bool onDeserialize>
346  services::Status serialImpl(Archive *arch)
347  {
348  return daal::algorithms::PartialResult::serialImpl<Archive, onDeserialize>(arch);
349  }
350 };
351 typedef services::SharedPtr<PartialResult> PartialResultPtr;
352 
353 } // interface1
354 using interface1::InputIface;
355 using interface1::Input;
356 using interface1::DistributedInput;
357 using interface1::PartialResult;
358 using interface1::PartialResultPtr;
359 using interface1::Result;
360 using interface1::ResultPtr;
361 
362 }
363 }
365 }
366 }
367 }
368 
369 #endif
daal::step1Local
Definition: daal_defines.h:123
daal::algorithms::implicit_als::prediction::ratings::ModelInputId
ModelInputId
Definition: implicit_als_predict_ratings_types.h:70
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:303
daal::algorithms::implicit_als::prediction::ratings::interface1::PartialResult::~PartialResult
virtual ~PartialResult()
Definition: implicit_als_predict_ratings_types.h:310
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::interface1::Result
Base class to represent final results of the computation. Algorithm-specific final results are repres...
Definition: algorithm_types.h:309
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:121
daal::algorithms::implicit_als::prediction::ratings::itemsPartialModel
Definition: implicit_als_predict_ratings_types.h:85
daal::algorithms::implicit_als::prediction::ratings::allUsersAllItems
Definition: implicit_als_predict_ratings_types.h:62
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:193
daal::algorithms::implicit_als::prediction::ratings::Method
Method
Definition: implicit_als_predict_ratings_types.h:59
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:193
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:250
daal::algorithms::implicit_als::prediction::ratings::interface1::InputIface::getNumberOfUsers
virtual size_t getNumberOfUsers() const =0
daal::algorithms::implicit_als::prediction::ratings::PartialModelInputId
PartialModelInputId
Definition: implicit_als_predict_ratings_types.h:81
daal::algorithms::implicit_als::prediction::ratings::ResultId
ResultId
Definition: implicit_als_predict_ratings_types.h:105
daal::algorithms::implicit_als::prediction::ratings::model
Definition: implicit_als_predict_ratings_types.h:72
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:145
daal::algorithms::implicit_als::prediction::ratings::prediction
Definition: implicit_als_predict_ratings_types.h:107
daal::algorithms::implicit_als::prediction::ratings::finalResult
Definition: implicit_als_predict_ratings_types.h:97
daal::algorithms::implicit_als::prediction::ratings::usersPartialModel
Definition: implicit_als_predict_ratings_types.h:83
daal::algorithms::implicit_als::prediction::ratings::defaultDense
Definition: implicit_als_predict_ratings_types.h:61
daal::algorithms::implicit_als::prediction::ratings::interface1::InputIface::getNumberOfItems
virtual size_t getNumberOfItems() const =0
daal::algorithms::interface1::PartialResult
Base class to represent partial results of the computation. Algorithm-specific partial results are re...
Definition: algorithm_types.h:229
daal::algorithms::implicit_als::prediction::ratings::PartialResultId
PartialResultId
Definition: implicit_als_predict_ratings_types.h:95

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