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

algorithm_quality_metric_set_batch.h
1 /* file: algorithm_quality_metric_set_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 // Interface for the quality metric set in the batch processing mode.
21 //--
22 */
23 
24 #ifndef __ALGORITHM_QUALITY_METRIC_SET_BATCH_H__
25 #define __ALGORITHM_QUALITY_METRIC_SET_BATCH_H__
26 
27 #include "algorithms/algorithm_quality_metric_set_types.h"
28 
29 namespace daal
30 {
31 namespace algorithms
32 {
36 namespace quality_metric_set
37 {
38 
42 namespace interface1
43 {
52 class Batch
53 {
54 public:
55  InputAlgorithmsCollection inputAlgorithms;
57  Batch(bool useDefaultMetrics = true) : _useDefaultMetrics(useDefaultMetrics)
58  {}
59 
60  virtual ~Batch() {}
65  ResultCollectionPtr getResultCollection() { return _resultCollection; }
66 
71  InputDataCollectionPtr getInputDataCollection() { return _inputData; }
72 
78  services::Status compute()
79  {
80  this->_status = computeNoThrow();
81  return services::throwIfPossible(this->_status);
82  }
83 
89  services::Status computeNoThrow()
90  {
91  DAAL_CHECK(inputAlgorithms.size(), services::ErrorEmptyInputAlgorithmsCollection)
92  services::Status s;
93  for (size_t i = 0; i < inputAlgorithms.size(); i++)
94  {
95  size_t key = inputAlgorithms.getKeyByIndex((int)i);
96  inputAlgorithms[key]->setInput(_inputData->getInput(key).get());
97  s = inputAlgorithms[key]->computeNoThrow();
98  if (!s) break;
99  _resultCollection->add(key, inputAlgorithms[key]->getResult());
100  }
101  return s;
102  }
103 
108  services::SharedPtr<services::ErrorCollection> getErrors()
109  {
110  return _status.getCollection();
111  }
112 
113 protected:
114  virtual void initializeQualityMetrics() = 0;
115 
116  bool _useDefaultMetrics;
117  InputDataCollectionPtr _inputData;
118  ResultCollectionPtr _resultCollection;
119  services::Status _status;
120 };
122 } // namespace interface1
123 using interface1::Batch;
124 
125 } // namespace daal::algorithms::quality_metric_set
126 } // namespace daal::algorithms
127 } // namespace daal
128 #endif
daal::algorithms::quality_metric_set::interface1::InputAlgorithmsCollection::getKeyByIndex
size_t getKeyByIndex(int idx)
daal::algorithms::quality_metric_set::interface1::Batch::_inputData
InputDataCollectionPtr _inputData
Definition: algorithm_quality_metric_set_batch.h:117
daal::algorithms::quality_metric_set::interface1::Batch::computeNoThrow
services::Status computeNoThrow()
Definition: algorithm_quality_metric_set_batch.h:89
daal::algorithms::quality_metric_set::interface1::InputAlgorithmsCollection::size
size_t size() const
daal::algorithms::quality_metric_set::interface1::Batch::inputAlgorithms
InputAlgorithmsCollection inputAlgorithms
Definition: algorithm_quality_metric_set_batch.h:55
daal::algorithms::quality_metric_set::interface1::Batch::compute
services::Status compute()
Definition: algorithm_quality_metric_set_batch.h:78
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:52
daal::services::ErrorEmptyInputAlgorithmsCollection
Definition: error_indexes.h:406
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:50
daal::algorithms::quality_metric_set::interface1::Batch::getInputDataCollection
InputDataCollectionPtr getInputDataCollection()
Definition: algorithm_quality_metric_set_batch.h:71
daal::algorithms::quality_metric_set::interface1::Batch::getErrors
services::SharedPtr< services::ErrorCollection > getErrors()
Definition: algorithm_quality_metric_set_batch.h:108
daal::algorithms::quality_metric_set::interface1::Batch::getResultCollection
ResultCollectionPtr getResultCollection()
Definition: algorithm_quality_metric_set_batch.h:65

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