IGTD

The Image Generator for Tabular Data (IGTD) method transforms tabular data into images by arranging features according to their similarity. Initially, it creates a feature-distance ranking using a correlation, statistical, geometric, or distribution-based measure. Subsequently, it computes a matrix that represents the spatial distances between pixel positions in the image. Finally, IGTD rearranges the features to ensure that the feature-distance ranking closely matches the spatial arrangement in the image, refining the placement iteratively.

Synthetic image produced by the IGTD method.

Import IGTD

To import IGTD model use:

>>> from TINTOlib.igtd import IGTD
>>> model = IGTD()

Inherited base functionality

IGTD inherits from MappingMethod (see Base classes), so it also provides:

  • Feature coordinates: a feature-to-pixel mapping exported to features_positions.csv after fit/fit_transform.

  • Programmatic access: _get_features_mapping() returns the feature coordinates as a DataFrame once the model is fitted.

  • Shared utilities: saveHyperparameters / loadHyperparameters and the standard fit / transform / fit_transform workflow.

Hyperparameters & Configuration

When creating the IGTD class, some parameters can be modified. The parameters are:

Parameters

Description

Default value

Valid values

problem

The type of problem, defining how the images are grouped.

‘classification’

[‘classification’, ‘unsupervised’, ‘regression’]

transformer

Preprocessing transformations like scaling, normalization, etc.

MinMaxScaler()

Scikit Learn transformers or custom implementation inheriting CustomTransformer.

verbose

Show execution details in the terminal.

False

[True, False]

scale

The number of pixel rows and columns in the image. The product (rows x columns) must be greater than or equal to the number of features.

[6, 6]

list of two positive integers

fea_dist_method

Method to calculate pairwise distances between features.

‘Pearson’

[‘Pearson’, ‘Spearman’, ‘set’, ‘Euclidean’, ‘Wasserstein’, ‘Jensen’, ‘Geodesic’, ‘Tropical’]

image_dist_method

Method to calculate distances between pixels in the image.

‘Euclidean’

[‘Euclidean’, ‘Manhattan’]

error

Function to evaluate differences between feature and pixel distance rankings.

‘squared’

[‘squared’, ‘abs’]

max_step

Maximum number of iterations for the algorithm if it does not converge.

1000

integer

val_step

Number of steps to check gain on the objective function for convergence.

50

integer

switch_t

Threshold for error change rate to determine if switching features should occur.

0

integer

min_gain

Minimum improvement in the objective function to continue optimization.

0.00001

float

zoom

Multiplication factor determining the size of the saved image relative to the original size.

1

integer > 0

format

Output format using images with matplotlib with [0,255] range for pixel or using npy format.

‘png’

[‘png’, ‘npy’]

cmap

Color map to use with matplotlib.

‘gray’

‘viridis’, ‘plasma’, ‘inferno’, ‘magma’, ‘cividis’, ‘Greys’, etc.

random_seed

Seed for reproducibility.

1

integer

Feature-distance methods

fea_dist_method determines how relationships between columns are represented before IGTD optimizes their pixel positions:

  • Pearson and Spearman use linear and rank correlation, respectively.

  • set uses the Jaccard index and is intended for binary features without all-zero columns.

  • Euclidean uses the Euclidean distance between feature vectors.

  • Wasserstein compares the empirical distributions of pairs of features using the Wasserstein distance.

  • Jensen uses the Jensen-Shannon distance between feature vectors.

  • Geodesic embeds the features with Isomap and measures Euclidean distance in the resulting three-dimensional manifold representation.

  • Tropical uses tropical distance, which is based on the range of coordinate-wise differences between two feature vectors.

Code examples:

>>> model = IGTD(scale=[3,3], error="abs", val_step=60, cmap='viridis')
>>> distribution_model = IGTD(fea_dist_method="Wasserstein")
>>> manifold_model = IGTD(fea_dist_method="Geodesic")

All the parameters that aren’t specifically set will have their default values.

Functions

IGTD has the following functions:

Function

Description

Output

saveHyperparameters(filename)

Allows to save the defined parameters.

.pkl file with the configuration

loadHyperparameters(filename)

Load IGTD configuration previously saved with saveHyperparameters(filename)

  • filename: .pkl file path

fit(data)

Trains the model on the tabular data. This optimizes the feature arrangement matrix based on the chosen distance methods and error function.

  • data: A path to a CSV file or a Pandas DataFrame containing the features and targets. The target column must be the last column.

transform(data, folder)

Generates and saves synthetic images in a specified folder. Requires the model to be fitted first.

  • data: A path to a CSV file or a Pandas DataFrame containing the features and targets. The target column must be the last column.

  • folder: Path to the folder where the synthetic images will be saved.

Folders with synthetic images

fit_transform(data, folder)

Combines the training and image generation steps. Fits the model to the data and generates synthetic images in one step.

  • data: A path to a CSV file or a Pandas DataFrame containing the features and targets. The target column must be the last column.

  • folder: Path to the folder where the synthetic images will be saved.

Folders with synthetic images

  • The model must be fitted before using the transform method. If the model isn’t fitted, a RuntimeError will be raised.

Citation

Paper: https://doi.org/10.1038/s41598-021-90923-y

Code Repository: https://github.com/zhuyitan/igtd