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

algorithm_quality_metric_set_batch.h
1 /* file: algorithm_quality_metric_set_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 // Interface for the quality metric set in the batch processing mode.
45 //--
46 */
47 
48 #ifndef __ALGORITHM_QUALITY_METRIC_SET_BATCH_H__
49 #define __ALGORITHM_QUALITY_METRIC_SET_BATCH_H__
50 
51 #include "algorithms/algorithm_quality_metric_set_types.h"
52 
53 namespace daal
54 {
55 namespace algorithms
56 {
60 namespace quality_metric_set
61 {
62 
66 namespace interface1
67 {
76 class Batch
77 {
78 public:
79  InputAlgorithmsCollection inputAlgorithms;
81  Batch(bool useDefaultMetrics = true) : _useDefaultMetrics(useDefaultMetrics)
82  {}
83 
84  virtual ~Batch() {}
89  ResultCollectionPtr getResultCollection() { return _resultCollection; }
90 
95  InputDataCollectionPtr getInputDataCollection() { return _inputData; }
96 
102  services::Status compute()
103  {
104  this->_status = computeNoThrow();
105  return services::throwIfPossible(this->_status);
106  }
107 
113  services::Status computeNoThrow()
114  {
115  DAAL_CHECK(inputAlgorithms.size(), services::ErrorEmptyInputAlgorithmsCollection)
116  services::Status s;
117  for (size_t i = 0; i < inputAlgorithms.size(); i++)
118  {
119  size_t key = inputAlgorithms.getKeyByIndex((int)i);
120  inputAlgorithms[key]->setInput(_inputData->getInput(key).get());
121  s = inputAlgorithms[key]->computeNoThrow();
122  if (!s) break;
123  _resultCollection->add(key, inputAlgorithms[key]->getResult());
124  }
125  return s;
126  }
127 
132  services::SharedPtr<services::ErrorCollection> getErrors()
133  {
134  return _status.getCollection();
135  }
136 
137 protected:
138  virtual void initializeQualityMetrics() = 0;
139 
140  bool _useDefaultMetrics;
141  InputDataCollectionPtr _inputData;
142  ResultCollectionPtr _resultCollection;
143  services::Status _status;
144 };
146 } // namespace interface1
147 using interface1::Batch;
148 
149 } // namespace daal::algorithms::quality_metric_set
150 } // namespace daal::algorithms
151 } // namespace daal
152 #endif
daal::algorithms::quality_metric_set::interface1::Batch::compute
services::Status compute()
Definition: algorithm_quality_metric_set_batch.h:102
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::quality_metric_set::interface1::Batch
Provides methods to compute a quality metric set of an algorithm in the batch processing mode...
Definition: algorithm_quality_metric_set_batch.h:76
daal::algorithms::quality_metric_set::interface1::Batch::_inputData
InputDataCollectionPtr _inputData
Definition: algorithm_quality_metric_set_batch.h:141
daal::algorithms::quality_metric_set::interface1::InputAlgorithmsCollection::size
size_t size() const
daal::algorithms::quality_metric_set::interface1::Batch::getInputDataCollection
InputDataCollectionPtr getInputDataCollection()
Definition: algorithm_quality_metric_set_batch.h:95
daal::algorithms::quality_metric_set::interface1::Batch::inputAlgorithms
InputAlgorithmsCollection inputAlgorithms
Definition: algorithm_quality_metric_set_batch.h:79
daal::algorithms::quality_metric_set::interface1::Batch::computeNoThrow
services::Status computeNoThrow()
Definition: algorithm_quality_metric_set_batch.h:113
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::algorithms::quality_metric_set::interface1::Batch::getResultCollection
ResultCollectionPtr getResultCollection()
Definition: algorithm_quality_metric_set_batch.h:89
daal::algorithms::quality_metric_set::interface1::InputAlgorithmsCollection
Class that implements functionality of the collection of quality metrics algorithms.
Definition: algorithm_quality_metric_set_types.h:74
daal::algorithms::quality_metric_set::interface1::InputAlgorithmsCollection::getKeyByIndex
size_t getKeyByIndex(int idx)
daal::services::interface1::Status::getCollection
ErrorCollectionPtr getCollection() const
daal::services::ErrorEmptyInputAlgorithmsCollection
Definition: error_indexes.h:415
daal::algorithms::quality_metric_set::interface1::Batch::getErrors
services::SharedPtr< services::ErrorCollection > getErrors()
Definition: algorithm_quality_metric_set_batch.h:132

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