DistanceMatrix

The DistanceMatrix method represents tabular data as a distance matrix, where pairwise distances between all normalized variables (scaled between [0,1]) are calculated and visualized in grayscale. In this visualization, closer values are represented by lighter shades, whereas further values appear darker.

DistanceMatrix method where distances represent feature relationships.

Import DistanceMatrix

To import DistanceMatrix model use:

>>> from TINTOlib.distancematrix import DistanceMatrix
>>> model = DistanceMatrix()

Hyperparameters & Configuration

When creating the DistanceMatrix 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]

zoom

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

1

integer > 0

Code example:

>>> model = DistanceMatrix(problem='regression', zoom=2)

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

Functions

DistanceMatrix has the following functions:

Function

Description

Output

saveHyperparameters(filename)

Allows to save the defined parameters.

.pkl file with the configuration

loadHyperparameters(filename)

Load DistanceMatrix configuration previously saved with saveHyperparameters(filename)

  • filename: .pkl file path

fit(data)

Trains the model on the tabular data. For DistanceMatrix, this step primarily handles setup as the transformation is stateless.

  • 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-022-26378-6

Code Repository: https://github.com/anuraganands/Non-image-data-classification-with-CNN