Txeo v0.1
A Developer-Friendly TensorFlow C++ Wrapper
Loading...
Searching...
No Matches
txeo::DataTableNorm< T > Class Template Reference

A normalizer for DataTable objects that handles feature scaling. More...

#include <DataTableNorm.h>

Collaboration diagram for txeo::DataTableNorm< T >:
Collaboration graph

Public Member Functions

 DataTableNorm ()=default
 
 DataTableNorm (const DataTableNorm &)=delete
 
 DataTableNorm (DataTableNorm &&)=default
 
DataTableNormoperator= (const DataTableNorm &)=delete
 
DataTableNormoperator= (DataTableNorm &&)=default
 
 ~DataTableNorm ()=default
 
 DataTableNorm (const txeo::DataTable< T > &data, txeo::NormalizationType type=txeo::NormalizationType::MIN_MAX)
 Construct a new DataTableNorm object with associated DataTable.
 
const txeo::DataTable< T > & data_table () const
 Get the associated DataTable.
 
void set_data_table (const txeo::DataTable< T > &data)
 Set a new DataTable for normalization.
 
txeo::NormalizationType type () const
 Get the current normalization type.
 
txeo::Matrix< Tnormalize (txeo::Matrix< T > &&x) const
 Normalize a matrix using rvalue semantics (move data)
 
txeo::Matrix< Tnormalize (const txeo::Matrix< T > &x) const
 Normalize a copy of the input matrix.
 
txeo::Matrix< Tx_train_normalized ()
 Get normalized training data.
 
txeo::Matrix< Tx_eval_normalized ()
 Get normalized evaluation data.
 
txeo::Matrix< Tx_test_normalized ()
 Get normalized test data.
 

Detailed Description

template<typename T>
class txeo::DataTableNorm< T >

A normalizer for DataTable objects that handles feature scaling.

This class provides normalization functionality for machine learning datasets stored in DataTable format. It supports both Min-Max scaling and Z-Score standardization, computing normalization parameters from the training data.

Template Parameters
TThe data type of the table elements (e.g., float, double)
Note
The normalizer computes normalization parameters (min/max or mean/std) from the training portion of the DataTable. Make sure the DataTable is properly initialized with training data before use.

Definition at line 26 of file DataTableNorm.h.

Constructor & Destructor Documentation

◆ DataTableNorm() [1/4]

template<typename T >
txeo::DataTableNorm< T >::DataTableNorm ( )
default

◆ DataTableNorm() [2/4]

template<typename T >
txeo::DataTableNorm< T >::DataTableNorm ( const DataTableNorm< T > &  )
delete

◆ DataTableNorm() [3/4]

template<typename T >
txeo::DataTableNorm< T >::DataTableNorm ( DataTableNorm< T > &&  )
default

◆ ~DataTableNorm()

template<typename T >
txeo::DataTableNorm< T >::~DataTableNorm ( )
default

◆ DataTableNorm() [4/4]

Construct a new DataTableNorm object with associated DataTable.

Parameters
dataReference to the DataTable containing training data
typeNormalization type (MIN_MAX or Z_SCORE)
Exceptions
DataTableNormError

Example Usage:

// Normalize a new sample
txeo::Matrix<double> sample = {{1.5}, {2.0}, {3.5}};
auto normalized_sample = normalizer.normalize(sample);
A container for managing training, evaluation, and test data splits.
Definition DataTable.h:24

Member Function Documentation

◆ data_table()

template<typename T >
const txeo::DataTable< T > & txeo::DataTableNorm< T >::data_table ( ) const
inline

Get the associated DataTable.

Returns
const txeo::DataTable<T>& Reference to the stored DataTable

Example Usage:

// Inspect the data table used for normalization
const auto& dt = normalizer.data_table();
std::cout << "Original dataset size: " << dt.x_train().rows() << std::endl;
const txeo::Matrix< T > & x_train() const
Returns training inputs matrix.
Definition DataTable.h:287

Definition at line 68 of file DataTableNorm.h.

68{ return *_data_table; }

◆ normalize() [1/2]

template<typename T >
txeo::Matrix< T > txeo::DataTableNorm< T >::normalize ( const txeo::Matrix< T > &  x) const
inline

Normalize a copy of the input matrix.

Parameters
xInput matrix to normalize
Returns
txeo::Matrix<T> Normalized copy of the matrix

Example Usage:

txeo::Matrix<double> original = {{1.0}, {2.0}, {3.0}};
auto normalized = normalizer.normalize(original); // Preserve original

Definition at line 127 of file DataTableNorm.h.

127 {
128 return this->normalize(x.clone());
129 };
DataTable< T > clone() const
txeo::Matrix< T > normalize(txeo::Matrix< T > &&x) const
Normalize a matrix using rvalue semantics (move data)
Here is the call graph for this function:

◆ normalize() [2/2]

template<typename T >
txeo::Matrix< T > txeo::DataTableNorm< T >::normalize ( txeo::Matrix< T > &&  x) const

Normalize a matrix using rvalue semantics (move data)

Parameters
xInput matrix to normalize (will be moved from)
Returns
txeo::Matrix<T> Normalized matrix
Exceptions
DataTableNormErrorIf normalization parameters not initialized

Example Usage:

// Efficiently normalize without copying
auto normalized = normalizer.normalize(std::move(large_matrix));
Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename T >
DataTableNorm & txeo::DataTableNorm< T >::operator= ( const DataTableNorm< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
DataTableNorm & txeo::DataTableNorm< T >::operator= ( DataTableNorm< T > &&  )
default

◆ set_data_table()

template<typename T >
void txeo::DataTableNorm< T >::set_data_table ( const txeo::DataTable< T > &  data)

Set a new DataTable for normalization.

Parameters
dataNew DataTable to use for normalization parameters
Exceptions
DataTableNormErrorIf DataTable is invalid

Example Usage:

normalizer.set_data_table(new_data); // Update normalization parameters

◆ type()

template<typename T >
txeo::NormalizationType txeo::DataTableNorm< T >::type ( ) const
inline

Get the current normalization type.

Returns
txeo::NormalizationType Active normalization method

Example Usage:

std::cout << "Using Min-Max normalization" << std::endl;
}

Definition at line 96 of file DataTableNorm.h.

96{ return _type; }

◆ x_eval_normalized()

template<typename T >
txeo::Matrix< T > txeo::DataTableNorm< T >::x_eval_normalized ( )

Get normalized evaluation data.

Returns
txeo::Matrix<T> Normalized evaluation dataset

Example Usage:

auto x_eval_norm = normalizer.x_eval_normalized();
auto eval_score = model.evaluate(x_eval_norm, normalizer.data_table().y_eval());
const txeo::Matrix< T > * y_eval() const
Returns a pointer to evaluation output matrix.

◆ x_test_normalized()

template<typename T >
txeo::Matrix< T > txeo::DataTableNorm< T >::x_test_normalized ( )

Get normalized test data.

Returns
txeo::Matrix<T> Normalized test dataset

Example Usage:

auto x_test_norm = normalizer.x_test_normalized();
auto test_acc = model.test(x_test_norm, normalizer.data_table().y_test());
const txeo::Matrix< T > * y_test() const
Returns a pointer to test output matrix.

◆ x_train_normalized()

template<typename T >
txeo::Matrix< T > txeo::DataTableNorm< T >::x_train_normalized ( )

Get normalized training data.

Returns
txeo::Matrix<T> Normalized training dataset
Exceptions
DataTableNormErrorIf training data not available

Example Usage:

auto x_train_norm = normalizer.x_train_normalized();
model.train(x_train_norm, normalizer.data_table().y_train());
const txeo::Matrix< T > & y_train() const
Returns training outputs matrix.
Definition DataTable.h:294

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