forpy 2

classificationerror.h
Go to the documentation of this file.
1 /* Author: Christoph Lassner. */
2 #pragma once
3 #ifndef FORPY_IMPURITIES_CLASSIFICATIONERROR_H_
4 #define FORPY_IMPURITIES_CLASSIFICATIONERROR_H_
5
6 #include "../global.h"
7
8 #include "../util/serialization/basics.h"
9
10 #include <limits>
11 #include <vector>
12
13 #include "../util/exponentials.h"
14 #include "./ientropyfunction.h"
15
16 namespace forpy {
22 class ClassificationError : public IEntropyFunction {
23 public:
24 ClassificationError();
25 ~ClassificationError();
26
27 inline float operator()(const float *class_members_numbers, const size_t &n,
28 const float &fsum) const {
29 // Deal with the special case quickly.
30 if (fsum == 0.f) return 0.f;
31
32 return 1.f -
33 *std::max_element(class_members_numbers, class_members_numbers + n) /
34 fsum;
35 }
36
37 inline friend std::ostream &operator<<(std::ostream &stream,
38 const ClassificationError & /*self*/) {
39 stream << "forpy::ClassificationError";
40 return stream;
41 };
42 bool operator==(const IEntropyFunction &rhs) const;
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(ClassificationError);
46
47 friend class cereal::access;
48 template <class Archive>
49 void serialize(Archive &ar, const uint &) {
50 ar(cereal::make_nvp("base", cereal::base_class<IEntropyFunction>(this)));
51 }
52 };
53 } // namespace forpy
54
55 CEREAL_REGISTER_TYPE(forpy::ClassificationError);
56 #endif // FORPY_IMPURITIES_CLASSIFICATIONERROR_H_
forpy::ClassificationError::serialize
void serialize(Archive &ar, const uint &)
Definition: classificationerror.h:49
forpy::ClassificationError::operator()
float operator()(const float *class_members_numbers, const size_t &n, const float &fsum) const
Definition: classificationerror.h:27
forpy::IEntropyFunction
Interface for an entropy calculation functor.
Definition: ientropyfunction.h:26
forpy::ClassificationError::~ClassificationError
~ClassificationError()
forpy::ClassificationError::ClassificationError
ClassificationError()
forpy
Definition: fastdprov.h:13
ientropyfunction.h
forpy::ClassificationError::DISALLOW_COPY_AND_ASSIGN
DISALLOW_COPY_AND_ASSIGN(ClassificationError)
CEREAL_REGISTER_TYPE
CEREAL_REGISTER_TYPE(forpy::ClassificationError)
forpy::ClassificationError::operator==
bool operator==(const IEntropyFunction &rhs) const
forpy::ClassificationError::operator<<
friend std::ostream & operator<<(std::ostream &stream, const ClassificationError &)
Definition: classificationerror.h:37
forpy::uint
unsigned int uint
Convenience typedef for unsigned int.
Definition: types.h:113
forpy::ClassificationError::access
friend class cereal::access
Definition: classificationerror.h:47
forpy::ClassificationError
Computes the classification error as .
Definition: classificationerror.h:22