PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
Public Member Functions | Private Attributes | List of all members
plssvm::data_set< T, U >::label_mapper Class Reference

Implements all necessary functionality to map arbitrary labels to labels usable by the C-SVMs. More...

#include <data_set.hpp>

Public Member Functions

 label_mapper (const std::vector< label_type > &labels)
 Create a mapping from all labels to { -1 , 1 } and vice versa. More...
 
const real_typeget_mapped_value_by_label (const label_type &label) const
 Given the original label value, return the mapped label value. More...
 
const label_typeget_label_by_mapped_value (const real_type &mapped_value) const
 Given the mapped label value, return the original label value. More...
 
size_type num_mappings () const noexcept
 Returns the number of valid mappings. This is equivalent to the number of different labels. More...
 
std::vector< label_typelabels () const
 Return a vector containing the different, original labels of the current data set. More...
 

Private Attributes

std::map< label_type, real_typelabel_to_mapped_ {}
 A mapping from the label to its mapped value, i.e., { -1 , 1 }.
 
std::map< real_type, label_typemapped_to_label_ {}
 A mapping from the mapped value, i.e., { -1 , 1 } to the original label value.
 

Detailed Description

template<typename T, typename U = int>
class plssvm::data_set< T, U >::label_mapper

Implements all necessary functionality to map arbitrary labels to labels usable by the C-SVMs.

Currently maps all labels to { -1 , 1 }.

Constructor & Destructor Documentation

◆ label_mapper()

template<typename T , typename U = int>
plssvm::data_set< T, U >::label_mapper::label_mapper ( const std::vector< label_type > &  labels)
explicit

Create a mapping from all labels to { -1 , 1 } and vice versa.

Parameters
[in]labelsthe labels to map
Note
Currently only binary classification is supported, i.e., only two different labels may be provided!
Exceptions
plssvm::data_set_exceptionif not exatcly two different labels are provided

Member Function Documentation

◆ get_mapped_value_by_label()

template<typename T , typename U >
auto plssvm::data_set< T, U >::label_mapper::get_mapped_value_by_label ( const label_type label) const

Given the original label value, return the mapped label value.

Parameters
[in]labelthe original label value
Exceptions
plssvm::data_set_exceptionif the original label value does not exist in this mapping
Returns
the mapped label value ([[nodiscard]])

◆ get_label_by_mapped_value()

template<typename T , typename U >
auto plssvm::data_set< T, U >::label_mapper::get_label_by_mapped_value ( const real_type mapped_value) const

Given the mapped label value, return the original label value.

Parameters
[in]mapped_valuethe mapped label value
Exceptions
plssvm::data_set_exceptionif the mapped label value does not exist in this mapping
Returns
the original label value ([[nodiscard]])

◆ num_mappings()

template<typename T , typename U >
auto plssvm::data_set< T, U >::label_mapper::num_mappings
noexcept

Returns the number of valid mappings. This is equivalent to the number of different labels.

Returns
the number of valid mapping entries ([[nodiscard]])

◆ labels()

template<typename T , typename U >
auto plssvm::data_set< T, U >::label_mapper::labels

Return a vector containing the different, original labels of the current data set.

Returns
the original labels ([[nodiscard]])

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