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

implicit_als_predict_ratings_batch.h
1 /* file: implicit_als_predict_ratings_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 // Implementation of the interface for implicit ALS model-based ratings prediction
45 // in the batch processing mode
46 //--
47 */
48 
49 #ifndef __IMPLICIT_ALS_PREDICT_RATINGS_BATCH_H__
50 #define __IMPLICIT_ALS_PREDICT_RATINGS_BATCH_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "algorithms/implicit_als/implicit_als_predict_ratings_types.h"
54 
55 namespace daal
56 {
57 namespace algorithms
58 {
59 namespace implicit_als
60 {
61 namespace prediction
62 {
63 namespace ratings
64 {
65 namespace interface1
66 {
79 template<typename algorithmFPType, Method method, CpuType cpu>
80 class DAAL_EXPORT BatchContainer : public PredictionContainerIface
81 {
82 public:
88  BatchContainer(daal::services::Environment::env *daalEnv);
90  ~BatchContainer();
95  services::Status compute() DAAL_C11_OVERRIDE;
96 };
97 
109 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
110 class Batch : public daal::algorithms::Prediction
111 {
112 public:
113  typedef algorithms::implicit_als::prediction::ratings::Input InputType;
114  typedef algorithms::implicit_als::Parameter ParameterType;
115  typedef algorithms::implicit_als::prediction::ratings::Result ResultType;
116 
117  InputType input;
118  ParameterType parameter;
123  Batch()
124  {
125  initialize();
126  }
127 
134  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
135  {
136  initialize();
137  }
138 
139  virtual ~Batch() {}
140 
145  ResultPtr getResult()
146  {
147  return _result;
148  }
149 
154  services::Status setResult(const ResultPtr &result)
155  {
156  DAAL_CHECK(result, services::ErrorNullResult)
157  _result = result;
158  _res = _result.get();
159  return services::Status();
160  }
161 
166  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
167 
173  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
174  {
175  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
176  }
177 
178 protected:
179  ResultPtr _result;
180 
181  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
182  {
183  return new Batch<algorithmFPType, method>(*this);
184  }
185 
186  services::Status allocateResult() DAAL_C11_OVERRIDE
187  {
188  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int)method);
189  _res = _result.get();
190  return s;
191  }
192 
193  void initialize()
194  {
195  _ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
196  _in = &input;
197  _par = &parameter;
198  _result.reset(new ResultType());
199  }
200 
201 };
203 } // interface1
204 using interface1::BatchContainer;
205 using interface1::Batch;
206 
207 }
208 }
209 }
210 }
211 }
212 #endif
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::parameter
ParameterType parameter
Definition: implicit_als_predict_ratings_batch.h:118
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:169
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:274
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: implicit_als_predict_ratings_batch.h:166
daal::algorithms::implicit_als::interface1::Parameter
Parameters for the compute() method of the implicit ALS algorithm.
Definition: implicit_als_model.h:82
daal::algorithms::neural_networks::prediction::prediction
Definition: neural_networks_prediction_result.h:79
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::input
InputType input
Definition: implicit_als_predict_ratings_batch.h:117
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:76
daal::algorithms::PredictionContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: prediction.h:66
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: implicit_als_predict_ratings_batch.h:154
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:80
daal::batch
Definition: daal_defines.h:132
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::services::interface1::SharedPtr::reset
void reset()
Definition: daal_shared_ptr.h:265
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::getResult
ResultPtr getResult()
Definition: implicit_als_predict_ratings_batch.h:145
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: implicit_als_predict_ratings_batch.h:134
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::Batch
Batch()
Definition: implicit_als_predict_ratings_batch.h:123
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch
Predicts the results of the implicit ALS algorithm.
Definition: implicit_als_predict_ratings_batch.h:110
daal::algorithms::implicit_als::prediction::ratings::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: implicit_als_predict_ratings_batch.h:173

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