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 DataFrames. 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.AbstractTransformationType

An 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.
source
TruncatedGaussianMixtures.TransformationType

A 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=[])

source
TruncatedGaussianMixtures.domain_columnsMethod

Return the domain columns of the specified transformation.

Arguments

  • Tr::AbstractTransformation: A transformation object.

Returns

  • A list of symbols corresponding to the domain columns.
source
TruncatedGaussianMixtures.forwardMethod

Apply 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.
source
TruncatedGaussianMixtures.forwardMethod

Return the forward transformation function of the specified transformation.

Arguments

  • Tr::AbstractTransformation: A transformation object.

Returns

  • The forward transformation function associated with Tr.
source
TruncatedGaussianMixtures.image_columnsMethod

Return 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.
source
TruncatedGaussianMixtures.inverseMethod

Apply 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.
source
TruncatedGaussianMixtures.inverseMethod

Return the inverse transformation function of the specified transformation.

Arguments

  • Tr::AbstractTransformation: A transformation object.

Returns

  • The inverse transformation function associated with Tr.
source