DeepInsight
The DeepInsight method transforms non-image tabular data into synthetic images by spatially arranging features based on their similarity. The process begins by applying dimensionality reduction techniques (such as t-SNE, PCA, or Kernel PCA) to project the feature space into a 2-dimensional plane. A convex hull algorithm is then employed to identify the smallest rectangle encompassing the feature points, which is subsequently rotated to align with the image axes. Finally, the feature values are mapped to the corresponding pixel locations within this grid. This structured arrangement ensures that correlated features are placed in proximity, enabling Convolutional Neural Networks (CNNs) to exploit local spatial dependencies effectively. This implementation extends the original method by adding techniques for mapping features to pixels. Furthemore, a new method to compute pixels values when using PCA is added
Import DeepInsight
To import DeepInsight model use:
>>> from TINTOlib.deepInsight import DeepInsight
>>> model = DeepInsight(image_dim=30)
Inherited base functionality
DeepInsight inherits from ParamImageMethod (see Base classes), so it also provides:
Feature coordinates: a feature-to-pixel mapping exported to
features_positions.csvafterfit/fit_transform.Programmatic access:
_get_features_mapping()returns the feature coordinates as a DataFrame once the model is fitted.Shared utilities:
saveHyperparameters/loadHyperparametersand the standardfit/transform/fit_transformworkflow.
Hyperparameters & Configuration
When creating the DeepInsight class, some parameters can be modified. The parameters are:
Parameters |
Description |
Default value |
Valid values |
|---|---|---|---|
|
Order size for a square matrix image. |
Required |
integer |
|
The type of problem, defining how the images are grouped. |
‘classification’ |
[‘classification’, ‘unsupervised’, ‘regression’] |
|
Preprocessing transformations like scaling, normalization, etc. |
MinMaxScaler() |
Scikit Learn transformers or custom implementation inheriting CustomTransformer. |
|
Show execution details in the terminal. |
False |
[True, False] |
|
Dimensionality reduction algorithm to determine feature coordinates. |
‘PCA’ |
[‘PCA’, ‘t-SNE’, ‘kPCA’] |
|
Technique to map features to pixels. |
‘bin’ |
str (e.g., ‘bin’) |
|
Relocate features so that each pixel can represent a single feature (only if algorithm_rd is ‘PCA’). |
False |
[True, False] |
|
Optimization algorithm applied in the pixel assignment stage. |
‘linear_sum’ |
str (e.g., ‘linear_sum’) |
|
Technique to calculate pixel values sharing multiple features. |
‘avg’ |
‘avg’ |
|
Multiplication factor determining the size of the saved image relative to the original size. |
1 |
integer > 0 |
|
Output format using images with matplotlib with [0,255] range for pixel or using npy format. |
‘png’ |
[‘png’, ‘npy’] |
|
Color map to use with matplotlib. |
‘gray’ |
‘viridis’, ‘plasma’, ‘inferno’, ‘magma’, ‘cividis’, ‘Greys’, etc. |
|
Seed for reproducibility. |
23 |
integer |
Code example:
>>> model = DeepInsight(image_dim=50, algorithm_rd='t-SNE', cmap='viridis', random_seed=42)
All the parameters that aren’t specifically set will have their default values.
Functions
DeepInsight has the following functions:
Function |
Description |
Output |
|---|---|---|
|
Allows to save the defined parameters. |
.pkl file with the configuration |
|
Load DeepInsight configuration previously saved with
|
|
|
Trains the model on the tabular data. This step performs dimensionality reduction to map features to the 2D grid.
|
|
|
Generates and saves synthetic images in a specified folder. Requires the model to be fitted first.
|
Folders with synthetic images |
|
Combines the training and image generation steps. Fits the model to the data and generates synthetic images in one step.
|
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-019-47765-6
Code Repository: https://github.com/alok-ai-lab/pyDeepInsight