### Install Transtab from Local Clone Source: https://github.com/ryanwangzf/transtab/blob/main/docs/source/install.md Clone the Transtab repository locally and install it using pip. This method is useful for development or when direct pip installation fails. ```bash git clone https://github.com/RyanWangZf/transtab.git cd transtab pip install . ``` -------------------------------- ### Load Dataset and Start Training Source: https://github.com/ryanwangzf/transtab/blob/main/examples/transfer_learning_regressor.ipynb Placeholder comment indicating the next step is to load a dataset and begin supervised training. ```python # load a dataset and start vanilla supervised training ``` -------------------------------- ### Install Transtab from GitHub using Pip Source: https://github.com/ryanwangzf/transtab/blob/main/docs/source/install.md Use this command to install the latest version of Transtab directly from its GitHub repository. ```bash pip install git+https://github.com/RyanWangZf/transtab.git ``` -------------------------------- ### Example Dataset Configuration Source: https://github.com/ryanwangzf/transtab/blob/main/docs/source/data_preparation.md This dictionary defines the structure and parameters for a custom dataset, including column types, binary indicators, and data splits. ```python EXAMPLE_DATACONFIG = { "example": { # dataset name "bin": ["bin1", "bin2"], # binary column names "cat": ["cat1", "cat2"], # categorical column names "num": ["num1", "num2"], # numerical column names "cols": ["bin1", "bin2", "cat1", "cat2", "num1", "num2"], # all column names "binary_indicator": ["1", "yes", "true", "positive", "t", "y"], # binary indicators in the binary columns, which will be converted to 1 "data_split_idx": { "train":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], # row indices for training set "val":[10, 11, 12, 13, 14, 15, 16, 17, 18, 19], # row indices for validation set "test":[20, 21, 22, 23, 24, 25, 26, 27, 28, 29], # row indices for test set } } } ``` -------------------------------- ### Install OpenML Package Source: https://github.com/ryanwangzf/transtab/blob/main/examples/transfer_learning_regressor.ipynb Installs the OpenML package, which is required for loading datasets from the OpenML repository using Transtab. ```bash pip install openml ``` -------------------------------- ### Install Package from TestPyPI Source: https://github.com/ryanwangzf/transtab/blob/main/pypi_build_commands.txt Install a specific version of your package from the TestPyPI repository. This is useful for verifying that the package installs and functions correctly from the test index. ```bash pip install --index-url https://test.pypi.org/simple/ transtab==0.0.2c ``` -------------------------------- ### Install Rust Toolchain for Tokenizers Build Source: https://github.com/ryanwangzf/transtab/blob/main/docs/source/install.md If you encounter build errors related to 'tokenizers' on MAC/Linux, install the Rust toolchain using this command. This is a prerequisite for building certain dependencies. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Start Contrastive Pretraining Training Source: https://github.com/ryanwangzf/transtab/blob/main/examples/contrastive_learning.ipynb Initiates the contrastive pretraining process with specified training arguments. The 'output_dir' parameter specifies where the model checkpoints will be saved. ```python # start contrastive pretraining training training_arguments = { 'num_epoch':50, 'batch_size':64, 'lr':1e-4, 'eval_metric':'val_loss', 'eval_less_is_better':True, 'output_dir':'./checkpoint' } transtab.train(model, trainset, valset, collate_fn=collate_fn, **training_arguments) ``` -------------------------------- ### Basic Usage of transtab for Supervised Learning Source: https://github.com/ryanwangzf/transtab/blob/main/docs/source/index.md This snippet demonstrates the fundamental steps for using transtab, including loading data, building a classifier, training the model, and making predictions. Ensure you have the transtab library installed and the necessary dataset available. ```python import transtab # load dataset by specifying dataset name allset, trainset, valset, testset, cat_cols, num_cols, bin_cols \ = transtab.load_data('credit-g') # build classifier model = transtab.build_classifier(cat_cols, num_cols, bin_cols) # start training transtab.train(model, trainset, valset, **training_arguments) # make predictions, df_x is a pd.DataFrame with shape (n, d) # return the predictions ypred with shape (n, 1) if binary classification; # (n, n_class) if multiclass classification. ypred = transtab.predict(model, df_x) ``` -------------------------------- ### Configure and Start Training Source: https://github.com/ryanwangzf/transtab/blob/main/examples/table_embedding.ipynb Defines training arguments and initiates the contrastive pretraining process using Transtab's train function. Ensure trainset, valset, and collate_fn are properly defined before execution. ```python training_arguments = { 'num_epoch':50, 'batch_size':64, 'lr':1e-4, 'eval_metric':'val_loss', 'eval_less_is_better':True, 'output_dir':'./checkpoint' } transtab.train(model, trainset, valset, collate_fn=collate_fn, **training_arguments) ``` -------------------------------- ### Configure and Start Transtab Model Training Source: https://github.com/ryanwangzf/transtab/blob/main/examples/contrastive_learning.ipynb Define training parameters such as the number of epochs, evaluation metric, and output directory. Then, initiate the training process using the transtab.train function with the model, training set, and validation set. ```python training_arguments = { 'num_epoch':50, 'eval_metric':'val_loss', 'eval_less_is_better':True, 'output_dir':'./checkpoint' } transtab.train(model, trainset, valset, **training_arguments) ``` -------------------------------- ### Training Progress Output Source: https://github.com/ryanwangzf/transtab/blob/main/examples/fast_train.ipynb Example output showing the progress of model training, including epoch number, validation loss, training loss, learning rate, and time spent. ```text Epoch: 0%| | 0/50 [00:00