Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::src::basic_gaussian_oracle< I, S > Class Template Reference

#include <oracle.h>

Inheritance diagram for ultra::src::basic_gaussian_oracle< I, S >:
ultra::src::basic_class_oracle ultra::src::basic_oracle

Public Member Functions

 basic_gaussian_oracle (const I &, const dataframe &, std::vector< std::string >={})
 basic_gaussian_oracle (std::istream &, const symbol_set &)
classification_result tag (const std::vector< value_t > &) const final
bool is_valid () const final
bool save (std::ostream &) const final
Public Member Functions inherited from ultra::src::basic_class_oracle
value_t operator() (const std::vector< value_t > &) const final
 Returns the predicted class label.
std::string name (const value_t &) const final
 Returns the class name, falling back to a numeric name for unknown IDs.

Static Public Attributes

static const std::string SERIALIZE_ID

Additional Inherited Members

Protected Member Functions inherited from ultra::src::basic_class_oracle
 basic_class_oracle (std::vector< std::string >={})
bool load_names (std::istream &)
 Loads the class names, accepting a zero count for omitted names.
bool save_names (std::ostream &) const
 Saves a count followed by one class name per line.
Static Protected Member Functions inherited from ultra::src::basic_class_oracle
static std::vector< std::string > class_names (const dataframe &)
 Collects the class names from the training set.

Detailed Description

template<class I, bool S>
class ultra::src::basic_gaussian_oracle< I, S >

Oracle for the Gaussian Distribution Classification.

Template Parameters
Iindividual
Sstores the individual inside vs keep a reference only
See also
ultra::src::gaussian_evaluator for further details.

Constructor & Destructor Documentation

◆ basic_gaussian_oracle() [1/2]

template<class I, bool S>
basic_gaussian_oracle::basic_gaussian_oracle ( const I & ind,
const dataframe & d,
std::vector< std::string > names = {} )
Parameters
[in]indprogram "to be transformed" into an oracle
[in]dthe training set
[in]namesoptional class names

◆ basic_gaussian_oracle() [2/2]

template<class I, bool S>
basic_gaussian_oracle::basic_gaussian_oracle ( std::istream & in,
const symbol_set & ss )

Constructs the object reading data from an input stream.

Parameters
[in]ininput stream
[in]ssactive symbol set

Member Function Documentation

◆ is_valid()

template<class I, bool S>
bool basic_gaussian_oracle::is_valid ( ) const
nodiscardfinalvirtual
Returns
true if the object passes the internal consistency check

Implements ultra::src::basic_oracle.

◆ save()

template<class I, bool S>
bool basic_gaussian_oracle::save ( std::ostream & out) const
finalvirtual

Saves the oracle on persistent storage.

Parameters
[out]outoutput stream
Returns
true on success

Implements ultra::src::basic_oracle.

◆ tag()

template<class I, bool S>
classification_result basic_gaussian_oracle::tag ( const std::vector< value_t > & ex) const
nodiscardfinalvirtual

Classifies an example using Gaussian class models and returns a confidence-weighted prediction.

Parameters
[in]exinput example to classify
Returns
a classification_result containing the predicted class label and an associated confidence value (the value is in the [0,1] interval and the sum of all the confidence levels of each class equals 1)

This method assigns a class label to an input example by evaluating the program oracle and comparing the result against a set of per-class Gaussian distributions previously constructed by fill_vector().

Inference modes

The behaviour depends on the availability of a valid oracle output:

  • Normal inference (oracle output available) The inferred value is compared to each class distribution using a Gaussian-like likelihood score:

    $$ p_i = \exp\left(-\frac{(x - \mu_i)^2}{\sigma_i^2}\right) $$

    where $\mu_i$ and $\sigma_i^2$ are the mean and variance of the distribution associated with class $i$. Degenerate or nearly-degenerate distributions (very small variance) are treated as point masses centred at the mean.

  • Missing inference (oracle output unavailable) If the oracle cannot produce a value for the input, the classifier falls back to class priors, selecting the most frequent class based on the effective sample counts stored in the Gaussian models.

    These counts include both real observations and synthetic samples added during variance inflation in fill_vector() and therefore represent effective class support rather than raw dataset frequencies.

Confidence semantics

The returned confidence is a normalised measure in the range $[0, 1]$:

  • in normal inference, it is defined as:

    $$ \text{confidence} = \frac{p_{\text{best}}}{\sum_i p_i} $$

    and represents how dominant the selected class likelihood is relative to the others;

  • in missing inference, it is defined as:

    $$ \text{confidence} = \frac{n_{\text{best}}}{\sum_i n_i} $$

    where $n_i$ is the effective sample count of class $i$.

A confidence close to 1 indicates a clear decision, while lower values signal ambiguity or weak evidence.

Special cases

  • If only one class is present, that class is returned with confidence 1;
  • the method assumes that fill_vector() has been called beforehand and that each class model contains at least one sample.
See also
fill_vector

Classifies an example using Gaussian class models and returns a confidence-weighted prediction.

Parameters
[in]exinput example to classify
Returns
a classification_result containing the predicted class label and an associated confidence value (the value is in the [0,1] interval and the sum of all the confidence levels of each class equals 1)

This method assigns a class label to an input example by evaluating the program oracle and comparing the result against a set of per-class Gaussian distributions previously constructed by fill_vector().

Inference modes

The behaviour depends on the availability of a valid oracle output:

  • Normal inference (oracle output available) The inferred value is compared to each class distribution using a Gaussian-like likelihood score:

    $$ p_i = \exp\left(-\frac{(x - \mu_i)^2}{\sigma_i^2}\right) $$

    where $\mu_i$ and $\sigma_i^2$ are the mean and variance of the distribution associated with class $i$. Degenerate or nearly-degenerate distributions (very small variance) are treated as point masses centred at the mean.

  • Missing inference (oracle output unavailable) If the oracle cannot produce a value for the input, the classifier falls back to class priors, selecting the most frequent class based on the effective sample counts stored in the Gaussian models.

    These counts include both real observations and synthetic samples added during variance inflation in fill_vector() and therefore represent effective class support rather than raw dataset frequencies.

Confidence semantics

The returned confidence is a normalised measure in the range $[0, 1]$:

  • in normal inference, it is defined as:

    $$ \text{confidence} = \frac{p_{\text{best}}}{\sum_i p_i} $$

    and represents how dominant the selected class likelihood is relative to the others;

  • in missing inference, it is defined as:

    $$ \text{confidence} = \frac{n_{\text{best}}}{\sum_i n_i} $$

    where $n_i$ is the effective sample count of class $i$.

A confidence close to 1 indicates a clear decision, while lower values signal ambiguity or weak evidence.

Special cases

  • If only one class is present, that class is returned with confidence 1;
  • the method assumes that fill_vector() has been called beforehand and that each class model contains at least one sample.
See also
fill_vector

Implements ultra::src::basic_oracle.


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