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

implicit_als_predict_ratings_batch.h
1 /* file: implicit_als_predict_ratings_batch.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 interface for implicit ALS model-based ratings prediction
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __IMPLICIT_ALS_PREDICT_RATINGS_BATCH_H__
26 #define __IMPLICIT_ALS_PREDICT_RATINGS_BATCH_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "algorithms/implicit_als/implicit_als_predict_ratings_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace implicit_als
36 {
37 namespace prediction
38 {
39 namespace ratings
40 {
41 namespace interface1
42 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class BatchContainer : public PredictionContainerIface
57 {
58 public:
64  BatchContainer(daal::services::Environment::env *daalEnv);
66  ~BatchContainer();
71  services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
85 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
86 class Batch : public daal::algorithms::Prediction
87 {
88 public:
89  typedef algorithms::implicit_als::prediction::ratings::Input InputType;
90  typedef algorithms::implicit_als::Parameter ParameterType;
91  typedef algorithms::implicit_als::prediction::ratings::Result ResultType;
92 
93  InputType input;
94  ParameterType parameter;
99  Batch()
100  {
101  initialize();
102  }
103 
110  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
111  {
112  initialize();
113  }
114 
115  virtual ~Batch() {}
116 
121  ResultPtr getResult()
122  {
123  return _result;
124  }
125 
130  services::Status setResult(const ResultPtr &result)
131  {
132  DAAL_CHECK(result, services::ErrorNullResult)
133  _result = result;
134  _res = _result.get();
135  return services::Status();
136  }
137 
142  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
143 
149  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
150  {
151  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
152  }
153 
154 protected:
155  ResultPtr _result;
156 
157  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
158  {
159  return new Batch<algorithmFPType, method>(*this);
160  }
161 
162  services::Status allocateResult() DAAL_C11_OVERRIDE
163  {
164  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
165  _res = _result.get();
166  return s;
167  }
168 
169  void initialize()
170  {
171  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
172  _in = &input;
173  _par = &parameter;
174  _result.reset(new ResultType());
175  }
176 
177 };
179 } // interface1
180 using interface1::BatchContainer;
181 using interface1::Batch;
182 
183 }
184 }
185 }
186 }
187 }
188 #endif
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch
Predicts the results of the implicit ALS algorithm.
Definition: implicit_als_predict_ratings_batch.h:86
daal::algorithms::implicit_als::prediction::ratings::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::batch
Definition: daal_defines.h:112
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:55
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: implicit_als_predict_ratings_batch.h:142
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: implicit_als_predict_ratings_batch.h:130
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:56
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::Batch
Batch()
Definition: implicit_als_predict_ratings_batch.h:99
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::input
InputType input
Definition: implicit_als_predict_ratings_batch.h:93
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:42
daal::algorithms::implicit_als::prediction::ratings::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::implicit_als::prediction::ratings::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: implicit_als_predict_ratings_batch.h:149
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::getResult
ResultPtr getResult()
Definition: implicit_als_predict_ratings_batch.h:121
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::parameter
ParameterType parameter
Definition: implicit_als_predict_ratings_batch.h:94
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:52
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: implicit_als_predict_ratings_batch.h:110

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