BarGraph
The BarGraph method transforms tabular data into grayscale images by representing features as equidistant bars, each scaled according to its normalized value.
Import BarGraph
To import BarGraph model use:
>>> from TINTOlib.bargraph import BarGraph
>>> model = BarGraph()
Hyperparameters & Configuration
When creating the BarGraph 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 width of each bar in pixels. |
1 |
integer > 0 |
|
The gap between bars in pixels. |
0 |
integer >= 0 |
|
Multiplication factor determining the size of the saved image relative to the original size. |
1 |
integer > 0 |
Code example:
>>> model = BarGraph(problem='regression', pixel_width=2, gap=1, zoom=2)
All the parameters that aren’t specifically set will have their default values.
Functions
BarGraph has the following functions:
Function |
Description |
Output |
|---|---|---|
|
Allows to save the defined parameters. |
.pkl file with the configuration |
|
Load BarGraph configuration previously saved with
|
|
|
Trains the model on the tabular data. For BarGraph, this step primarily handles setup as the transformation is stateless.
|
|
|
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-022-26378-6
Code Repository: https://github.com/anuraganands/Non-image-data-classification-with-CNN