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

binary_confusion_matrix_batch.h
1 /* file: binary_confusion_matrix_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 binary confusion matrix algorithm in the batch processing mode
19 //--
20 */
21 
22 #ifndef __BINARY_CONFUSION_MATRIX_BATCH_H__
23 #define __BINARY_CONFUSION_MATRIX_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/classifier/binary_confusion_matrix_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace classifier
33 {
34 namespace quality_metric
35 {
36 namespace binary_confusion_matrix
37 {
38 
39 namespace interface1
40 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
55 {
56 public:
62  BatchContainer(daal::services::Environment::env *daalEnv);
64  virtual ~BatchContainer();
68  virtual services::Status compute() DAAL_C11_OVERRIDE;
69 };
70 
84 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
85 class DAAL_EXPORT Batch : public daal::algorithms::quality_metric::Batch
86 {
87 public:
88  typedef algorithms::classifier::quality_metric::binary_confusion_matrix::Input InputType;
89  typedef algorithms::classifier::quality_metric::binary_confusion_matrix::Parameter ParameterType;
90  typedef algorithms::classifier::quality_metric::binary_confusion_matrix::Result ResultType;
91 
92  InputType input;
93  ParameterType parameter;
96  Batch()
97  {
98  initialize();
99  }
100 
107  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
108  {
109  initialize();
110  }
111 
116  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
117 
122  ResultPtr getResult() const
123  {
124  return _result;
125  }
126 
131  services::Status setResult(const ResultPtr& result)
132  {
133  DAAL_CHECK(result, services::ErrorNullResult)
134  _result = result;
135  _res = _result.get();
136  return services::Status();
137  }
138 
143  virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
144  {
145  const InputType *inputPtr = static_cast<const InputType *>(other);
146  input.set(predictedLabels, inputPtr->get(predictedLabels));
147  input.set(groundTruthLabels, inputPtr->get(groundTruthLabels));
148  }
149 
155  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
156  {
157  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
158  }
159 
160 protected:
161  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
162  {
163  return new Batch<algorithmFPType, method>(*this);
164  }
165 
166  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
167  {
168  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
169  _res = _result.get();
170  return s;
171  }
172 
173  virtual algorithms::ResultPtr getResultImpl() const DAAL_C11_OVERRIDE
174  {
175  return _result;
176  }
177 
178  void initialize()
179  {
180  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
181  _in = &input;
182  _par = &parameter;
183  _result.reset(new ResultType());
184  }
185 
186 private:
187  ResultPtr _result;
188 };
190 } // namespace interface1
191 using interface1::BatchContainer;
192 using interface1::Batch;
193 
194 }
195 }
196 }
197 }
198 }
199 #endif
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::setInput
virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
Definition: binary_confusion_matrix_batch.h:143
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: binary_confusion_matrix_batch.h:116
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::parameter
ParameterType parameter
Definition: binary_confusion_matrix_batch.h:93
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::input
InputType input
Definition: binary_confusion_matrix_batch.h:92
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: binary_confusion_matrix_batch.h:131
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::getResult
ResultPtr getResult() const
Definition: binary_confusion_matrix_batch.h:122
daal::batch
Definition: daal_defines.h:106
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::predictedLabels
Definition: binary_confusion_matrix_types.h:70
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::Batch
Batch()
Definition: binary_confusion_matrix_batch.h:96
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: binary_confusion_matrix_batch.h:107
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::groundTruthLabels
Definition: binary_confusion_matrix_types.h:71
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::BatchContainer
Class containing methods to compute the confusion matrix for a binary classifier. ...
Definition: binary_confusion_matrix_batch.h:54
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: binary_confusion_matrix_batch.h:155
daal::algorithms::classifier::quality_metric::binary_confusion_matrix::interface1::Batch
Computes the confusion matrix for a binary classifier in the batch processing mode.
Definition: binary_confusion_matrix_batch.h:85

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