FeatureWrap
The FeatureWrap method transforms tabular data into synthetic images by encoding features as binary vectors. Categorical data are one-hot encoded, while numerical data are normalized, discretized, and then encoded. These binary vectors are concatenated, padded if necessary, and converted into pixel values ranging from 0 to 255 to create the final image.
![FeatureWrap method image, encoding features as binary vectors transformed into pixel values.](https://raw.githubusercontent.com/oeg-upm/TINTOlib-Documentation/refs/heads/main/assets/Synthetic-images/FeatureWrap_264844_zoom.png)
Import FeatureWrap
To import FeatureWrap model use:
>>> from TINTOlib.featureWrap import FeatureWrap
>>> model = FeatureWrap()
Hyperparameters & Configuration
When creating the FeatureWrap
class, some parameters can be modified. The parameters are:
Parameters |
Description |
Default value |
Valid values |
---|---|---|---|
|
Defines how the images are grouped based on the type of problem. |
‘supervised’ |
[‘supervised’, ‘unsupervised’, ‘regression’] |
|
Normalizes input data using MinMaxScaler if set to True. |
True |
[True, False] |
|
Displays execution details in the terminal if set to True. |
False |
[True, False] |
|
Specifies the width and height of the final image in pixels (rows x columns). |
(8, 8) |
tuple of two positive integers |
|
Determines the number of bins or intervals used for grouping numeric data. |
10 |
integer > 1 |
|
Sets the multiplication factor for resizing the image relative to its original size. |
1 |
integer > 0 |
Code example:
>>> model = FeatureWrap(size=[10,10], bins=20)
All the parameters that aren’t expecifically setted will have their default values.
Functions
FeatureWrap has the following functions:
Function |
Description |
Output |
---|---|---|
|
Allows to save the defined parameters (scale, fea_dost_method, image_dist_method, etc.) |
.pkl file with the configuration |
|
Load TINTO configuration previously saved with
|
|
|
Trains the model on the tabular data and prepares it for image generation.
|
|
|
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.1007/978-3-319-70139-4_87
Code Repository: