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

implicit_als_model.h
1 /* file: implicit_als_model.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Declaration of the implicit ALS model class
45 //--
46 */
47 
48 #ifndef __IMPLICIT_ALS_MODEL_H__
49 #define __IMPLICIT_ALS_MODEL_H__
50 
51 #include "algorithms/model.h"
52 #include "data_management/data/homogen_numeric_table.h"
53 
54 namespace daal
55 {
56 namespace algorithms
57 {
67 namespace implicit_als
68 {
69 
73 namespace interface1
74 {
81 /* [Parameter source code] */
82 struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter
83 {
92  Parameter(size_t nFactors = 10, size_t maxIterations = 5, double alpha = 40.0, double lambda = 0.01,
93  double preferenceThreshold = 0.0) :
94  nFactors(nFactors), maxIterations(maxIterations), alpha(alpha), lambda(lambda),
95  preferenceThreshold(preferenceThreshold)
96  {}
97 
98  size_t nFactors;
99  size_t maxIterations;
100  double alpha;
101  double lambda;
102  double preferenceThreshold;
104  services::Status check() const DAAL_C11_OVERRIDE;
105 };
106 /* [Parameter source code] */
107 
116 class DAAL_EXPORT Model : public daal::algorithms::Model
117 {
118 
119 public:
120  DECLARE_MODEL(Model, daal::algorithms::Model);
121 
130  template<typename modelFPType>
131  DAAL_EXPORT Model(size_t nUsers, size_t nItems, const Parameter &parameter, modelFPType dummy);
132 
137  Model();
138 
146  template<typename modelFPType>
147  DAAL_EXPORT static services::SharedPtr<Model> create(size_t nUsers, size_t nItems,
148  const Parameter &parameter,
149  services::Status *stat = NULL);
150 
151  virtual ~Model() { }
152 
158  data_management::NumericTablePtr getUsersFactors() const { return _usersFactors; }
159 
165  data_management::NumericTablePtr getItemsFactors() const { return _itemsFactors; }
166 
167 private:
168  data_management::NumericTablePtr _usersFactors; /* Table of resulting users factors */
169  data_management::NumericTablePtr _itemsFactors; /* Table of resulting items factors */
170 
171 protected:
172 
173  template<typename Archive, bool onDeserialize>
174  services::Status serialImpl(Archive *arch)
175  {
176  daal::algorithms::Model::serialImpl<Archive, onDeserialize>(arch);
177 
178  arch->setSharedPtrObj(_usersFactors);
179  arch->setSharedPtrObj(_itemsFactors);
180 
181  return services::Status();
182  }
183 
184  template<typename modelFPType>
185  DAAL_EXPORT Model(size_t nUsers, size_t nItems, const Parameter &parameter,
186  modelFPType dummy, services::Status &st);
187 
188 };
189 typedef services::SharedPtr<Model> ModelPtr;
190 
199 class DAAL_EXPORT PartialModel : public daal::algorithms::Model
200 {
201 public:
202  DECLARE_SERIALIZABLE_CAST(PartialModel);
203 
211  template<typename modelFPType>
212  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t size, modelFPType dummy);
213 
222  template<typename modelFPType>
223  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t offset,
224  data_management::NumericTablePtr indices, modelFPType dummy);
225 
232  PartialModel(data_management::NumericTablePtr factors,
233  data_management::NumericTablePtr indices);
234 
239  PartialModel();
240 
248  template<typename modelFPType>
249  DAAL_EXPORT static services::SharedPtr<PartialModel> create(const Parameter &parameter, size_t size,
250  services::Status *stat = NULL);
259  template<typename modelFPType>
260  DAAL_EXPORT static services::SharedPtr<PartialModel> create(const Parameter &parameter, size_t offset,
261  const data_management::NumericTablePtr &indices,
262  services::Status *stat = NULL);
270  static services::SharedPtr<PartialModel> create(const data_management::NumericTablePtr &factors,
271  const data_management::NumericTablePtr &indices,
272  services::Status *stat = NULL);
273 
274  virtual ~PartialModel() { }
275 
280  data_management::NumericTablePtr getFactors() const { return _factors; }
281 
286  data_management::NumericTablePtr getIndices() const { return _indices; }
287 
288 protected:
289  data_management::NumericTablePtr _factors; /* Factors in row-major format */
290  data_management::NumericTablePtr _indices; /* Indices of the factors */
291 
292  template<typename Archive, bool onDeserialize>
293  services::Status serialImpl(Archive *arch)
294  {
295  daal::algorithms::Model::serialImpl<Archive, onDeserialize>(arch);
296 
297  arch->setSharedPtrObj(_factors);
298  arch->setSharedPtrObj(_indices);
299 
300  return services::Status();
301  }
302 
303  template<typename modelFPType>
304  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t size, modelFPType dummy, services::Status &st);
305 
306  template<typename modelFPType>
307  DAAL_EXPORT PartialModel(const Parameter &parameter, size_t offset,
308  const data_management::NumericTablePtr &indices,
309  modelFPType dummy, services::Status &st);
310 
311  PartialModel(const data_management::NumericTablePtr &factors,
312  const data_management::NumericTablePtr &indices,
313  services::Status &st);
314 
315 private:
316  template<typename modelFPType>
317  DAAL_EXPORT services::Status initialize(const Parameter &parameter, size_t size);
318 
319  template<typename modelFPType>
320  DAAL_EXPORT services::Status initialize(const Parameter &parameter, size_t offset,
321  const data_management::NumericTablePtr &indices);
322 };
323 
324 typedef services::SharedPtr<PartialModel> PartialModelPtr;
325 } // namespace interface1
326 using interface1::Parameter;
327 using interface1::ModelPtr;
328 using interface1::Model;
329 using interface1::PartialModelPtr;
330 using interface1::PartialModel;
331 
332 }
334 }
335 }
336 
337 #endif
daal::algorithms::implicit_als::interface1::Parameter::lambda
double lambda
Definition: implicit_als_model.h:101
daal
Definition: algorithm_base_common.h:57
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:92
daal::algorithms::implicit_als::interface1::Parameter
Parameters for the compute() method of the implicit ALS algorithm.
Definition: implicit_als_model.h:82
daal::algorithms::implicit_als::interface1::Model::getItemsFactors
data_management::NumericTablePtr getItemsFactors() const
Definition: implicit_als_model.h:165
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:199
daal::algorithms::implicit_als::interface1::Model::getUsersFactors
data_management::NumericTablePtr getUsersFactors() const
Definition: implicit_als_model.h:158
daal::algorithms::implicit_als::interface1::PartialModel::getFactors
data_management::NumericTablePtr getFactors() const
Definition: implicit_als_model.h:280
daal::algorithms::implicit_als::interface1::Parameter::nFactors
size_t nFactors
Definition: implicit_als_model.h:98
daal::algorithms::implicit_als::interface1::Parameter::maxIterations
size_t maxIterations
Definition: implicit_als_model.h:99
daal::algorithms::implicit_als::interface1::PartialModel::getIndices
data_management::NumericTablePtr getIndices() const
Definition: implicit_als_model.h:286
daal::algorithms::implicit_als::interface1::Model
Model trained by the implicit ALS algorithm in the batch processing mode.
Definition: implicit_als_model.h:116
daal::algorithms::implicit_als::training::offset
Definition: implicit_als_training_types.h:174
daal::algorithms::implicit_als::interface1::Parameter::preferenceThreshold
double preferenceThreshold
Definition: implicit_als_model.h:102
daal::algorithms::implicit_als::interface1::Parameter::alpha
double alpha
Definition: implicit_als_model.h:100

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