forpy 2

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
forpy::EntropyGain Class Reference
Gains

Calculates the gain as difference of current entropy and the weighted sum of subgroup entropies. More...

`#include <entropygain.h>`

Inheritance diagram for forpy::EntropyGain:

## Public Member Functions
| EntropyGain (const std::shared_ptr< IEntropyFunction > &entropy_function)
float | approx (const std::vector< float > &members_numbers_left, const std::vector< float > &members_numbers_right)
float | operator() (const float &current_entropy, const std::vector< float > &members_numbers_left, const std::vector< float > &members_numbers_right)
float | operator() (const std::vector< float > &members_numbers_left, const std::vector< float > &members_numbers_right)
bool | operator== (const IGainCalculator &rhs) const
std::shared_ptr< IEntropyFunction > | getEntropy_function () const
Public Member Functions inherited from forpy::IGainCalculator
virtual | ~IGainCalculator ()

## Protected Member Functions
| EntropyGain ()
Protected Member Functions inherited from forpy::IGainCalculator
| IGainCalculator ()

## Private Member Functions
template<class Archive >
void | serialize (Archive &ar, const uint &)

## Private Attributes
std::shared_ptr< IEntropyFunction > | entropy_function

## Friends
class | cereal::access

## Detailed Description

Calculates the gain as difference of current entropy and the weighted sum of subgroup entropies.

Works correctly up to a total sum of elements of min(numeric_limits<float>::max(), numeric_limits<input_dtype>::max()) and the limitations of the selected entropy function. Speed optimized function that does no checks in release mode!

Parameters

  input_dtype | The datatype for counting class members. This might be a float if sample weights are used.

Definition at line 34 of file entropygain.h.

## Constructor & Destructor Documentation

## ◆ EntropyGain() [1/2]

forpy::EntropyGain::EntropyGain | ( | const std::shared_ptr< IEntropyFunction > & | entropy_function | ) |
| inline explicit

Parameters

  entropy_function | shared(IEntropyFunction) The entropy to use for gain calculation.

Definition at line 40 of file entropygain.h.

## ◆ EntropyGain() [2/2]

forpy::EntropyGain::EntropyGain | ( |  | ) |
| inline protected

Definition at line 62 of file entropygain.h.

## Member Function Documentation

## ◆ approx()

float forpy::EntropyGain::approx | ( | const std::vector< float > & | members_numbers_left,
|  | const std::vector< float > & | members_numbers_right
| ) |  |
| virtual

Gets a gain approximation that can be used inside an `argmax` function.

Reimplemented from forpy::IGainCalculator.

## ◆ getEntropy_function()

std::shared_ptr<IEntropyFunction> forpy::EntropyGain::getEntropy_function | ( |  | ) | const

## ◆ operator()() [1/2]

float forpy::EntropyGain::operator() | ( | const float & | current_entropy,
|  | const std::vector< float > & | members_numbers_left,
|  | const std::vector< float > & | members_numbers_right
| ) |  |
| virtual

Calculates the information gain.

Reimplemented from forpy::IGainCalculator.

## ◆ operator()() [2/2]

float forpy::EntropyGain::operator() | ( | const std::vector< float > & | members_numbers_left,
|  | const std::vector< float > & | members_numbers_right
| ) |  |
| virtual

Calculates the information gain.

Reimplemented from forpy::IGainCalculator.

## ◆ operator==()

bool forpy::EntropyGain::operator== | ( | const IGainCalculator & | rhs | ) | const
| virtual

Deep equality comparison.

Reimplemented from forpy::IGainCalculator.

## ◆ serialize()

template<class Archive >

void forpy::EntropyGain::serialize | ( | Archive & | ar,
|  | const uint & |
| ) |  |
| inline private

Definition at line 69 of file entropygain.h.

## Friends And Related Function Documentation

## ◆ cereal::access

friend class cereal::access
| friend

Definition at line 67 of file entropygain.h.

## Member Data Documentation

## ◆ entropy_function

std::shared_ptr<IEntropyFunction> forpy::EntropyGain::entropy_function
| private

Definition at line 65 of file entropygain.h.

The documentation for this class was generated from the following file:

- /Users/classner/git/forpy/include/forpy/gains/entropygain.h