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

implicit_als_model.h
1 /* file: implicit_als_model.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 // Declaration of the implicit ALS model class
19 //--
20 */
21 
22 #ifndef __IMPLICIT_ALS_MODEL_H__
23 #define __IMPLICIT_ALS_MODEL_H__
24 
25 #include "algorithms/model.h"
26 #include "data_management/data/homogen_numeric_table.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
41 namespace implicit_als
42 {
43 
47 namespace interface1
48 {
55 /* [Parameter source code] */
56 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
57 {
66  Parameter(size_t nFactors = 10, size_t maxIterations = 5, double alpha = 40.0, double lambda = 0.01,
67  double preferenceThreshold = 0.0) :
68  nFactors(nFactors), maxIterations(maxIterations), alpha(alpha), lambda(lambda),
69  preferenceThreshold(preferenceThreshold)
70  {}
71 
72  size_t nFactors;
73  size_t maxIterations;
74  double alpha;
75  double lambda;
76  double preferenceThreshold;
78  services::Status check() const DAAL_C11_OVERRIDE;
79 };
80 /* [Parameter source code] */
81 
90 class DAAL_EXPORT Model : public daal::algorithms::Model
91 {
92 
93 public:
94  DECLARE_MODEL(Model, daal::algorithms::Model);
95 
104  template<typename modelFPType>
105  DAAL_EXPORT Model(size_t nUsers, size_t nItems, const Parameter &parameter, modelFPType dummy);
106 
111  Model();
112 
120  template<typename modelFPType>
121  DAAL_EXPORT static services::SharedPtr<Model> create(size_t nUsers, size_t nItems,
122  const Parameter &parameter,
123  services::Status *stat = NULL);
124 
125  virtual ~Model() { }
126 
132  data_management::NumericTablePtr getUsersFactors() const { return _usersFactors; }
133 
139  data_management::NumericTablePtr getItemsFactors() const { return _itemsFactors; }
140 
141 private:
142  data_management::NumericTablePtr _usersFactors; /* Table of resulting users factors */
143  data_management::NumericTablePtr _itemsFactors; /* Table of resulting items factors */
144 
145 protected:
146 
147  template<typename Archive, bool onDeserialize>
148  services::Status serialImpl(Archive *arch)
149  {
150  daal::algorithms::Model::serialImpl<Archive, onDeserialize>(arch);
151 
152  arch->setSharedPtrObj(_usersFactors);
153  arch->setSharedPtrObj(_itemsFactors);
154 
155  return services::Status();
156  }
157 
158  template<typename modelFPType>
159  DAAL_EXPORT Model(size_t nUsers, size_t nItems, const Parameter &parameter,
160  modelFPType dummy, services::Status &st);
161 
162 };
163 typedef services::SharedPtr<Model> ModelPtr;
164 
173 class DAAL_EXPORT PartialModel : public daal::algorithms::Model
174 {
175 public:
176  DECLARE_SERIALIZABLE_CAST(PartialModel);
177 
185  template<typename modelFPType>
186  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t size, modelFPType dummy);
187 
196  template<typename modelFPType>
197  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t offset,
198  data_management::NumericTablePtr indices, modelFPType dummy);
199 
206  PartialModel(data_management::NumericTablePtr factors,
207  data_management::NumericTablePtr indices);
208 
213  PartialModel();
214 
222  template<typename modelFPType>
223  DAAL_EXPORT static services::SharedPtr<PartialModel> create(const Parameter &parameter, size_t size,
224  services::Status *stat = NULL);
233  template<typename modelFPType>
234  DAAL_EXPORT static services::SharedPtr<PartialModel> create(const Parameter &parameter, size_t offset,
235  const data_management::NumericTablePtr &indices,
236  services::Status *stat = NULL);
244  static services::SharedPtr<PartialModel> create(const data_management::NumericTablePtr &factors,
245  const data_management::NumericTablePtr &indices,
246  services::Status *stat = NULL);
247 
248  virtual ~PartialModel() { }
249 
254  data_management::NumericTablePtr getFactors() const { return _factors; }
255 
260  data_management::NumericTablePtr getIndices() const { return _indices; }
261 
262 protected:
263  data_management::NumericTablePtr _factors; /* Factors in row-major format */
264  data_management::NumericTablePtr _indices; /* Indices of the factors */
265 
266  template<typename Archive, bool onDeserialize>
267  services::Status serialImpl(Archive *arch)
268  {
269  daal::algorithms::Model::serialImpl<Archive, onDeserialize>(arch);
270 
271  arch->setSharedPtrObj(_factors);
272  arch->setSharedPtrObj(_indices);
273 
274  return services::Status();
275  }
276 
277  template<typename modelFPType>
278  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t size, modelFPType dummy, services::Status &st);
279 
280  template<typename modelFPType>
281  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t offset,
282  const data_management::NumericTablePtr &indices,
283  modelFPType dummy, services::Status &st);
284 
285  PartialModel(const data_management::NumericTablePtr &factors,
286  const data_management::NumericTablePtr &indices,
287  services::Status &st);
288 
289 private:
290  template<typename modelFPType>
291  DAAL_EXPORT services::Status initialize(const Parameter &parameter, size_t size);
292 
293  template<typename modelFPType>
294  DAAL_EXPORT services::Status initialize(const Parameter &parameter, size_t offset,
295  const data_management::NumericTablePtr &indices);
296 };
297 
298 typedef services::SharedPtr<PartialModel> PartialModelPtr;
299 } // namespace interface1
300 using interface1::Parameter;
301 using interface1::ModelPtr;
302 using interface1::Model;
303 using interface1::PartialModelPtr;
304 using interface1::PartialModel;
305 
306 }
308 }
309 }
310 
311 #endif
daal::algorithms::implicit_als::interface1::Parameter::lambda
double lambda
Definition: implicit_als_model.h:75
daal
Definition: algorithm_base_common.h:31
daal::algorithms::implicit_als::interface1::Parameter::Parameter
Parameter(size_t nFactors=10, size_t maxIterations=5, double alpha=40.0, double lambda=0.01, double preferenceThreshold=0.0)
Definition: implicit_als_model.h:66
daal::algorithms::implicit_als::interface1::Parameter
Parameters for the compute() method of the implicit ALS algorithm.
Definition: implicit_als_model.h:56
daal::algorithms::implicit_als::interface1::Model::getItemsFactors
data_management::NumericTablePtr getItemsFactors() const
Definition: implicit_als_model.h:139
daal::algorithms::implicit_als::interface1::PartialModel
Partial model trained by the implicit ALS training algorithm in the distributed processing mode...
Definition: implicit_als_model.h:173
daal::algorithms::implicit_als::interface1::Model::getUsersFactors
data_management::NumericTablePtr getUsersFactors() const
Definition: implicit_als_model.h:132
daal::algorithms::implicit_als::interface1::PartialModel::getFactors
data_management::NumericTablePtr getFactors() const
Definition: implicit_als_model.h:254
daal::algorithms::implicit_als::interface1::Parameter::nFactors
size_t nFactors
Definition: implicit_als_model.h:72
daal::algorithms::implicit_als::interface1::Parameter::maxIterations
size_t maxIterations
Definition: implicit_als_model.h:73
daal::algorithms::implicit_als::interface1::PartialModel::getIndices
data_management::NumericTablePtr getIndices() const
Definition: implicit_als_model.h:260
daal::algorithms::implicit_als::interface1::Model
Model trained by the implicit ALS algorithm in the batch processing mode.
Definition: implicit_als_model.h:90
daal::algorithms::implicit_als::training::offset
Definition: implicit_als_training_types.h:148
daal::algorithms::implicit_als::interface1::Parameter::preferenceThreshold
double preferenceThreshold
Definition: implicit_als_model.h:76
daal::algorithms::implicit_als::interface1::Parameter::alpha
double alpha
Definition: implicit_als_model.h:74

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