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

implicit_als_predict_ratings_batch.h
1 /* file: implicit_als_predict_ratings_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 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 interface for implicit ALS model-based ratings prediction
19 // in the batch processing mode
20 //--
21 */
22 
23 #ifndef __IMPLICIT_ALS_PREDICT_RATINGS_BATCH_H__
24 #define __IMPLICIT_ALS_PREDICT_RATINGS_BATCH_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "algorithms/implicit_als/implicit_als_predict_ratings_types.h"
28 
29 namespace daal
30 {
31 namespace algorithms
32 {
33 namespace implicit_als
34 {
35 namespace prediction
36 {
37 namespace ratings
38 {
39 namespace interface1
40 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
55 {
56 public:
62  BatchContainer(daal::services::Environment::env *daalEnv);
64  ~BatchContainer();
69  services::Status compute() DAAL_C11_OVERRIDE;
70 };
71 
83 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
84 class Batch : public daal::algorithms::Prediction
85 {
86 public:
87  typedef algorithms::implicit_als::prediction::ratings::Input InputType;
88  typedef algorithms::implicit_als::Parameter ParameterType;
89  typedef algorithms::implicit_als::prediction::ratings::Result ResultType;
90 
91  InputType input;
92  ParameterType parameter;
97  Batch()
98  {
99  initialize();
100  }
101 
108  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
109  {
110  initialize();
111  }
112 
113  virtual ~Batch() {}
114 
119  ResultPtr getResult()
120  {
121  return _result;
122  }
123 
128  services::Status setResult(const ResultPtr &result)
129  {
130  DAAL_CHECK(result, services::ErrorNullResult)
131  _result = result;
132  _res = _result.get();
133  return services::Status();
134  }
135 
140  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
141 
147  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
148  {
149  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
150  }
151 
152 protected:
153  ResultPtr _result;
154 
155  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
156  {
157  return new Batch<algorithmFPType, method>(*this);
158  }
159 
160  services::Status allocateResult() DAAL_C11_OVERRIDE
161  {
162  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
163  _res = _result.get();
164  return s;
165  }
166 
167  void initialize()
168  {
169  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
170  _in = &input;
171  _par = &parameter;
172  _result.reset(new ResultType());
173  }
174 
175 };
177 } // interface1
178 using interface1::BatchContainer;
179 using interface1::Batch;
180 
181 }
182 }
183 }
184 }
185 }
186 #endif
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::parameter
ParameterType parameter
Definition: implicit_als_predict_ratings_batch.h:92
daal
Definition: algorithm_base_common.h:31
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: implicit_als_predict_ratings_batch.h:140
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::input
InputType input
Definition: implicit_als_predict_ratings_batch.h:91
daal::algorithms::Prediction
Provides prediction methods depending on the model such as linear_regression::Model. The methods of the class support different computation modes: batch, distributed, and online(see ComputeMode). Classes that implement specific algorithms of the model based data prediction are derived classes of the Prediction class. The class additionally provides virtual methods for validation of input and output parameters of the algorithms.
Definition: prediction.h:50
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:40
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: implicit_als_predict_ratings_batch.h:128
daal::algorithms::implicit_als::prediction::ratings::interface1::BatchContainer
Provides methods to run implementations of the implicit ALS ratings prediction algorithm in the batch...
Definition: implicit_als_predict_ratings_batch.h:54
daal::batch
Definition: daal_defines.h:110
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::getResult
ResultPtr getResult()
Definition: implicit_als_predict_ratings_batch.h:119
daal::algorithms::classifier::prediction::prediction
Definition: classifier_predict_types.h:76
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: implicit_als_predict_ratings_batch.h:108
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::Batch
Batch()
Definition: implicit_als_predict_ratings_batch.h:97
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: implicit_als_predict_ratings_batch.h:147
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch
Predicts the results of the implicit ALS algorithm.
Definition: implicit_als_predict_ratings_batch.h:84

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