SuperTML
The SuperTML method transforms tabular data into synthetic images by drawing data values directly onto a 3-channel (RGB) image. Each feature is assigned a specific region on the image, depicted as text representing the numerical value. SuperTML offers two distinct variations:
SuperTML_EF (Equal Font): - This approach assigns equally sized regions for each feature and uses a uniform font size across the image, ensuring that all features are treated equally in terms of visual representation.
SuperTML_VF (Variable Font): - In this variation, the size of the region and the font size are adjusted based on the feature’s importance (calculated via Random Forest). More significant features receive larger regions and font sizes, highlighting key features more prominently.
Import SuperTML
To import SuperTML model use:
>>> from TINTOlib.supertml import SuperTML
>>> model = SuperTML()
⚠️ Font Requirements
SuperTML generates text-based synthetic images and strictly requires the Arial font (arial.ttf) for correct rendering.
On Windows, this font is typically available by default.
On Linux and macOS, it must be installed manually if not present to avoid OSError: cannot open resource when generating images.
To ensure the font is available:
Linux
Install the Microsoft Core Fonts:
sudo apt install ttf-mscorefonts-installer
macOS
Use Homebrew to install the fonts:
brew tap homebrew/cask-fonts
brew install --cask font-arial
Google Colab
On Google Colab, you may need to upload arial.ttf to the working directory or install the font package, as it is not always available by default.
Hyperparameters & Configuration
When creating the SuperTML class, some parameters can be modified. The parameters are:
Parameters |
Description |
Default value |
Valid values |
|---|---|---|---|
|
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] |
|
The number of pixels used to create the image (one side). Total pixels = pixels * pixels. |
224 |
integer |
|
If False, SuperTML-EF (Equal Font) is used. If True, SuperTML-VF (Variable Font) is used, scaling font size by feature importance. |
False |
[True, False] |
|
The base size of the font used to render text on the generated images. |
10 |
integer |
|
Seed for reproducibility. |
1 |
integer |
Code example:
>>> model = SuperTML(problem='regression', feature_importance=True, pixels=224, font_size=12)
All the parameters that aren’t specifically set will have their default values.
Functions
SuperTML 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 SuperTML 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.ieeecomputersociety.org/10.1109/CVPRW.2019.00360
Code Repository: https://github.com/GilesStrong/SuperTML_HiggsML_Test