Skip to main content

PyTorch autoencoder with additional embeddings layer for categorical data.

Project description

The Autoembedder

docs license mypy black isort pre-commit

Introduction

The Autoembedder is an autoencoder with additional embedding layers for the categorical columns. Its usage is flexible, and hyperparameters like the number of layers can be easily adjusted and tuned. Although primarily designed for Panda's dataframes, it can be easily modified to support other data structures.

Let's get started

training.py is where everything begins. The following arguments can / should be set:

Argument Type Required Default value Comment
batch_size int False 32
drop_last int False 1 True/False
pin_memory int False 1 True/False
num_workers int False 0 0 means that the data will be loaded in the main process
use_mps int False 0 Set this to 1 if you want to use the MPS Backend for running on Mac using the M1 GPU. process
model_title str False autoembedder_{datetime}.bin
model_save_path str False
n_save_checkpoints int False
lr float False 0.001
amsgrad int False 0 True/False
epochs int True
layer_bias int False 1 True/False
weight_decay float False 0
l1_lambda float False 0
xavier_init int False 0 True/False
tensorboard_log_path str False
train_input_path str True
test_input_path str True
activation_for_code_layer int False 0 True/False, should the layer have an activation
activation_for_final_decoder_layer int False 0 True/False, should the final decoder layer have an activation
hidden_layer_representation str True Contains a string representation of a list of list of integers which represents the hidden layer structure. E.g.: "[[64, 32], [32, 16], [16, 8]]" activation
cat_columns str False "[]" Contains a string representation of a list of list of categorical columns (strings). The columns which use the same encoder should be together in a list. E.g.: "[['a', 'b'], ['c']]".

So, something like this would do it:

$ python3 training.py --epochs 20 \
--train_input_path "path/to/your/train_data" \
--test_input_path "path/to/your/test_data" \
--hidden_layer_representation "[[12, 6], [6, 3]]"

Why additional embedding layers?

The additional embedding layers automatically embed all columns with the Pandas category data type. If categorical columns have another data type, they will not be embedded and will be handled like the continuous columns. Simply encoding the categorical values (e.g., with the usage of a label encoder) decreases the quality of the outcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoembedder-0.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

autoembedder-0.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file autoembedder-0.1.tar.gz.

File metadata

  • Download URL: autoembedder-0.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0

File hashes

Hashes for autoembedder-0.1.tar.gz
Algorithm Hash digest
SHA256 faae5eec6b3720be4441bbd18740ea591d4c652be9a0062f88b5fedf74a7cba5
MD5 09740ecaaf7f8a9f8aa7fc504844b40a
BLAKE2b-256 01b59b03e77a75396f8625e71de9fc6ae3b2ec31d858b1f320a13f4d1f93e700

See more details on using hashes here.

File details

Details for the file autoembedder-0.1-py3-none-any.whl.

File metadata

  • Download URL: autoembedder-0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0

File hashes

Hashes for autoembedder-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e682c5556995139cca376ae588c1018b353bc9a8787c13bc645bb9925655c74d
MD5 a6544320d9fde246626048368cb79acd
BLAKE2b-256 1d38ef0776709ec6b234e1cf7e086a2ffed0292f8c3a6d97713c0af86defb398

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page