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

algorithm_quality_metric_set_batch.h
1 /* file: algorithm_quality_metric_set_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 // Interface for the quality metric set in the batch processing mode.
19 //--
20 */
21 
22 #ifndef __ALGORITHM_QUALITY_METRIC_SET_BATCH_H__
23 #define __ALGORITHM_QUALITY_METRIC_SET_BATCH_H__
24 
25 #include "algorithms/algorithm_quality_metric_set_types.h"
26 
27 namespace daal
28 {
29 namespace algorithms
30 {
34 namespace quality_metric_set
35 {
36 
40 namespace interface1
41 {
50 class Batch
51 {
52 public:
53  InputAlgorithmsCollection inputAlgorithms;
55  Batch(bool useDefaultMetrics = true) : _useDefaultMetrics(useDefaultMetrics)
56  {}
57 
58  virtual ~Batch() {}
63  ResultCollectionPtr getResultCollection() { return _resultCollection; }
64 
69  InputDataCollectionPtr getInputDataCollection() { return _inputData; }
70 
76  services::Status compute()
77  {
78  this->_status = computeNoThrow();
79  return services::throwIfPossible(this->_status);
80  }
81 
87  services::Status computeNoThrow()
88  {
89  DAAL_CHECK(inputAlgorithms.size(), services::ErrorEmptyInputAlgorithmsCollection)
90  services::Status s;
91  for (size_t i = 0; i < inputAlgorithms.size(); i++)
92  {
93  size_t key = inputAlgorithms.getKeyByIndex((int)i);
94  inputAlgorithms[key]->setInput(_inputData->getInput(key).get());
95  s = inputAlgorithms[key]->computeNoThrow();
96  if (!s) break;
97  _resultCollection->add(key, inputAlgorithms[key]->getResult());
98  }
99  return s;
100  }
101 
106  services::SharedPtr<services::ErrorCollection> getErrors()
107  {
108  return _status.getCollection();
109  }
110 
111 protected:
112  virtual void initializeQualityMetrics() = 0;
113 
114  bool _useDefaultMetrics;
115  InputDataCollectionPtr _inputData;
116  ResultCollectionPtr _resultCollection;
117  services::Status _status;
118 };
120 } // namespace interface1
121 using interface1::Batch;
122 
123 } // namespace daal::algorithms::quality_metric_set
124 } // namespace daal::algorithms
125 } // namespace daal
126 #endif
daal::algorithms::quality_metric_set::interface1::Batch::compute
services::Status compute()
Definition: algorithm_quality_metric_set_batch.h:76
daal::algorithms::quality_metric_set::interface1::InputAlgorithmsCollection::size
size_t size() const
daal
Definition: algorithm_base_common.h:31
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:50
daal::algorithms::quality_metric_set::interface1::Batch::_inputData
InputDataCollectionPtr _inputData
Definition: algorithm_quality_metric_set_batch.h:115
daal::algorithms::quality_metric_set::interface1::Batch::getInputDataCollection
InputDataCollectionPtr getInputDataCollection()
Definition: algorithm_quality_metric_set_batch.h:69
daal::algorithms::quality_metric_set::interface1::Batch::inputAlgorithms
InputAlgorithmsCollection inputAlgorithms
Definition: algorithm_quality_metric_set_batch.h:53
daal::algorithms::quality_metric_set::interface1::Batch::computeNoThrow
services::Status computeNoThrow()
Definition: algorithm_quality_metric_set_batch.h:87
daal::algorithms::quality_metric_set::interface1::Batch::getResultCollection
ResultCollectionPtr getResultCollection()
Definition: algorithm_quality_metric_set_batch.h:63
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:48
daal::algorithms::quality_metric_set::interface1::InputAlgorithmsCollection::getKeyByIndex
size_t getKeyByIndex(int idx)
daal::services::ErrorEmptyInputAlgorithmsCollection
Definition: error_indexes.h:395
daal::algorithms::quality_metric_set::interface1::Batch::getErrors
services::SharedPtr< services::ErrorCollection > getErrors()
Definition: algorithm_quality_metric_set_batch.h:106

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