Transformations in TGMM Fitting
This section describes how to use transformations to modify data in a way that aids in fitting Truncated Gaussian Mixture Models (TGMM) by changing the coordinate system.
AbstractTransformation
AbstractTransformation
is an abstract type that provides a blueprint for creating coordinate transformations on DataFrame
s. Transformations can modify how data is projected, helping to improve TGMM fitting performance by enabling users to operate in different coordinate systems.
Transformation Struct
Transformation is a concrete type implementing AbstractTransformation, allowing users to define custom transformations. Users can specify which columns represent the domain and image spaces and define functions for the forward and inverse transformations.
Fields
domain_columns
: Columns representing the domain of the transformation. forward
: The transformation function from domain to image. image_columns
: Columns in the transformed space. inverse
: The inverse transformation function. ignore_columns
: Columns that remain unchanged during transformations.
Example Usage
using DataFrames
df_cartesian = DataFrame(:x => [1.0, 3.0], :y => [0.0, 1.0], :label => [:cat, :dog])
# Define a Cartesian-to-Polar transformation
CartesianToPolar = Transformation(
[:x, :y],
(x, y) -> (√(x^2 + y^2), atan2(y, x)),
[:r, :θ],
(r, θ) -> (r * cos(θ), r * sin(θ)),
[:label]
)
# Apply forward transformation
df_polar = forward(CartesianToPolar, df_cartesian)
# Apply inverse transformation
df_cartesian_reconstructed = inverse(CartesianToPolar, df_polar)
Misc Documentation
TruncatedGaussianMixtures.AbstractTransformation
— TypeAn abstract type representing a coordinate transformation.
AbstractTransformation
is a supertype for transformations that can be applied to a DataFrame. It requires that any subtype define forward
, inverse
, domain_columns
, and image_columns
methods.
Required methods for subtypes
forward
: Defines the forward transformation.inverse
: Defines the inverse transformation.domain_columns
: Lists columns in the DataFrame that belong to the transformation's domain.image_columns
: Lists columns representing the transformed space.
TruncatedGaussianMixtures.Transformation
— TypeA concrete implementation of AbstractTransformation
for performing custom transformations on DataFrames.
Fields
domain_columns
: A vector of symbols representing the columns in the domain space.forward
: A function that maps domain columns to image columns.image_columns
: A vector of symbols representing the columns in the transformed space.inverse
: A function that maps image columns back to domain columns.ignore_columns
: A vector of columns to leave unchanged during transformation.
Constructor
Transformation(domain_columns, forward, image_columns, inverse; ignore_columns=[])
TruncatedGaussianMixtures.domain_columns
— MethodReturn the domain columns of the specified transformation.
Arguments
Tr::AbstractTransformation
: A transformation object.
Returns
- A list of symbols corresponding to the domain columns.
TruncatedGaussianMixtures.forward
— MethodApply the forward transformation to a DataFrame.
Transforms columns in the domain space to the image space, keeping other columns unchanged.
Arguments
Tr::AbstractTransformation
: A transformation object.df::DataFrame
: A DataFrame containing columns matching the domain.
Returns
- A DataFrame with transformed columns in the image space.
TruncatedGaussianMixtures.forward
— MethodReturn the forward transformation function of the specified transformation.
Arguments
Tr::AbstractTransformation
: A transformation object.
Returns
- The forward transformation function associated with
Tr
.
TruncatedGaussianMixtures.image_columns
— MethodReturn the image columns of the specified transformation.
Arguments
Tr::AbstractTransformation
: A transformation object.
Returns
- A list of symbols corresponding to the columns in the transformed space.
TruncatedGaussianMixtures.inverse
— MethodApply the inverse transformation to a DataFrame.
Transforms columns in the image space back to the domain space, keeping other columns unchanged.
Arguments
Tr::AbstractTransformation
: A transformation object.df::DataFrame
: A DataFrame containing columns in the image space.
Returns
- A DataFrame with transformed columns in the domain space.
TruncatedGaussianMixtures.inverse
— MethodReturn the inverse transformation function of the specified transformation.
Arguments
Tr::AbstractTransformation
: A transformation object.
Returns
- The inverse transformation function associated with
Tr
.