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

multiclass_confusion_matrix_batch.h
1 /* file: multiclass_confusion_matrix_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 multi-class confusion matrix algorithm in the batch processing mode
19 //--
20 */
21 
22 #ifndef __MULTICLASS_CONFUSION_MATRIX_BATCH_H__
23 #define __MULTICLASS_CONFUSION_MATRIX_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/classifier/multiclass_confusion_matrix_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace classifier
33 {
34 namespace quality_metric
35 {
36 namespace multiclass_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::multiclass_confusion_matrix::Input InputType;
89  typedef algorithms::classifier::quality_metric::multiclass_confusion_matrix::Parameter ParameterType;
90  typedef algorithms::classifier::quality_metric::multiclass_confusion_matrix::Result ResultType;
91 
92  InputType input;
93  ParameterType parameter;
99  Batch(size_t nClasses = 2) : parameter(nClasses)
100  {
101  initialize();
102  }
103 
110  Batch(const Batch<algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
111  {
112  initialize();
113  }
114 
119  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
120 
125  ResultPtr getResult() const
126  {
127  return _result;
128  }
129 
134  services::Status setResult(const ResultPtr& result)
135  {
136  DAAL_CHECK(result, services::ErrorNullResult)
137  _result = result;
138  _res = _result.get();
139  return services::Status();
140  }
141 
146  virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
147  {
148  const InputType *inputPtr = static_cast<const InputType *>(other);
149  input.set(predictedLabels, inputPtr->get(predictedLabels));
150  input.set(groundTruthLabels, inputPtr->get(groundTruthLabels));
151  }
152 
158  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
159  {
160  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
161  }
162 
163 protected:
164  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
165  {
166  return new Batch<algorithmFPType, method>(*this);
167  }
168 
169  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
170  {
171  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
172  _res = _result.get();
173  return s;
174  }
175 
176  virtual algorithms::ResultPtr getResultImpl() const DAAL_C11_OVERRIDE
177  {
178  return _result;
179  }
180 
181  void initialize()
182  {
183  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
184  _in = &input;
185  _par = &parameter;
186  _result.reset(new ResultType());
187  }
188 
189 private:
190  ResultPtr _result;
191 };
193 } // namespace interface1
194 using interface1::BatchContainer;
195 using interface1::Batch;
196 
197 }
198 }
199 }
200 }
201 }
202 #endif
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: multiclass_confusion_matrix_batch.h:134
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch
Computes the confusion matrix for a multi-class classifier in the batch processing mode...
Definition: multiclass_confusion_matrix_batch.h:85
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::multiclass_confusion_matrix::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: multiclass_confusion_matrix_batch.h:110
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch::Batch
Batch(size_t nClasses=2)
Definition: multiclass_confusion_matrix_batch.h:99
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch::parameter
ParameterType parameter
Definition: multiclass_confusion_matrix_batch.h:93
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::BatchContainer
Class containing methods to compute the confusion matrix for the multi-class classifier.
Definition: multiclass_confusion_matrix_batch.h:54
daal::batch
Definition: daal_defines.h:110
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::predictedLabels
Definition: multiclass_confusion_matrix_types.h:65
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: multiclass_confusion_matrix_batch.h:158
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch::setInput
virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
Definition: multiclass_confusion_matrix_batch.h:146
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::multiclass_confusion_matrix::interface1::Batch::getResult
ResultPtr getResult() const
Definition: multiclass_confusion_matrix_batch.h:125
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch::input
InputType input
Definition: multiclass_confusion_matrix_batch.h:92
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::groundTruthLabels
Definition: multiclass_confusion_matrix_types.h:66
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::classifier::quality_metric::multiclass_confusion_matrix::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: multiclass_confusion_matrix_batch.h:119

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