### Run Quickstart Experiment Source: https://github.com/mlfoundations/tableshift/blob/main/examples/README.md Execute a single experiment to test your setup. This is a good starting point for verifying your installation. ```bash python run_expt.py --experiment adult --model histgbm ``` -------------------------------- ### Run Container to Test Installation Source: https://github.com/mlfoundations/tableshift/blob/main/docker/README.md Execute the container with a sample script to verify your Docker setup. Mounts a local tmp directory for output. ```bash docker run -v $(pwd)/tmp:/tableshift/tmp tableshift --model lightgbm ``` -------------------------------- ### Get ANES Dataset Source: https://github.com/mlfoundations/tableshift/blob/main/docs/datasets.md Verify installation by fetching the ANES dataset. The data will be automatically downloaded to the cache if not already present. ```python from tableshift import get_dataset dset = get_dataset("anes") ``` -------------------------------- ### Run Docker Container for Testing Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Run the Docker container and automatically launch the example script to test your setup. The --model argument specifies the model to use. ```bash docker run ghcr.io/jpgard/tableshift:latest --model xgb ``` -------------------------------- ### Test Conda Environment Installation Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Test the Conda environment installation by running the main training script. Successful execution will show 'training completed!' with an accuracy score. ```bash python examples/run_expt.py ``` -------------------------------- ### Run Container Interactively Source: https://github.com/mlfoundations/tableshift/blob/main/docker/README.md Start the Docker container in interactive mode, providing a bash shell. Mounts a local tmp directory. ```bash docker run -it --entrypoint=/bin/bash -v $(pwd)/tmp:/tableshift/tmp tableshift ``` -------------------------------- ### Run Distributed Hyperparameter Tuning with Ray Source: https://github.com/mlfoundations/tableshift/blob/main/examples/README.md Conduct hyperparameter tuning using Ray. This example demonstrates a toy run with specified experiment, sample count, worker configuration, and model selection. ```bash ulimit -u 127590 && python scripts/ray_train.py \ --experiment adult \ --num_samples 2 \ --num_workers 1 \ --cpu_per_worker 4 \ --use_cached \ --models xgb ``` -------------------------------- ### Fetch Docker Image Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Fetch the latest TableShift Docker image from Docker Hub. This is the recommended method for environment setup. ```bash docker pull ghcr.io/jpgard/tableshift:latest ``` -------------------------------- ### Get a Standard TableShift Dataset Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Load a standard version of a public TableShift dataset using its name. The 'diabetes_readmission' dataset is used as an example. ```python from tableshift import get_dataset dataset_name = "diabetes_readmission" dset = get_dataset(dataset_name) ``` -------------------------------- ### Train Single XGBoost Model Source: https://github.com/mlfoundations/tableshift/blob/main/examples/README.md Train a single XGBoost model on the UCI Adult dataset for testing or debugging your setup. ```bash python run_expt.py --experiment adult --model xgb ``` -------------------------------- ### Train Single Tabular ResNet Model Source: https://github.com/mlfoundations/tableshift/blob/main/examples/README.md Train a single Tabular ResNet model on the UCI Adult dataset for testing or debugging your setup. ```bash python run_expt.py --experiment adult --model resnet ``` -------------------------------- ### Train and Tune CatBoost Model with Optuna Source: https://github.com/mlfoundations/tableshift/blob/main/examples/README.md Train and tune a CatBoost model using Optuna, as CatBoost is not officially supported in Ray. This script allows for hyperparameter tuning with specified experiment and sample count. ```bash python scripts/train_catboost_optuna.py --experiment $EXPERIMENT --use_cached --num_samples 100 ``` -------------------------------- ### Build the TableShift Docker Image Locally Source: https://github.com/mlfoundations/tableshift/blob/main/docker/README.md Build the Docker image from the local Dockerfile. Ensure you are in the project root directory. ```bash docker build -t tableshift -f docker/tableshift.dockerfile . ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Set up a Conda environment for TableShift by creating an environment from the 'environment.yml' file and activating it. ```bash conda env create -f environment.yml conda activate tableshift ``` -------------------------------- ### Cache Data for Experiments Source: https://github.com/mlfoundations/tableshift/blob/main/examples/README.md Cache datasets before running experiments. Caching fetches, preprocesses, and splits remote data, writing it to disk for efficient distributed training and handling large datasets. ```bash python scripts/cache_task.py --experiment $EXPERIMENT ``` -------------------------------- ### Accessing Datasets with TableShift Source: https://github.com/mlfoundations/tableshift/blob/main/benchmarking_guide.md Use `get_dataset` to fetch benchmark data. Supports Pandas DataFrames and PyTorch DataLoaders. Ensure the `experiment` name and `cache_dir` are correctly specified. ```python from tableshift import get_dataset experiment = "diabetes_readmission" # can be any TableShift dataset name dset = get_dataset(experiment, cache_dir) # For Pandas DataFrames X, y, _, _ = dset.get_pandas("train") X_test_id, y_test_id, _, _ = dset.get_pandas("test") X_test_ood, y_test_ood, _, _ = dset.get_pandas("ood_test") # PyTorch DataLoader train_loader = dset.get_dataloader("train", batch_size=1024) id_test_loader = dset.get_dataloader("test", batch_size=1024) ood_test_loader = dset.get_dataloader("ood_test", batch_size=1024) ``` -------------------------------- ### Pull the TableShift Docker Image Source: https://github.com/mlfoundations/tableshift/blob/main/docker/README.md Use this command to pull the pre-built TableShift container from Docker Hub. ```bash docker pull ``` -------------------------------- ### Run Docker Container Interactively Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Run the Docker container interactively, providing a bash shell for development or exploration within the container. ```bash docker run -it --entrypoint=/bin/bash ghcr.io/jpgard/tableshift:latest ``` -------------------------------- ### Run TableShift Experiment Source: https://github.com/mlfoundations/tableshift/blob/main/reproduction_guide.md Execute a TableShift experiment using the `ray_train.py` script. This command can be used with different model and dataset names. ```bash python scripts/ray_train.py \ --models mlp \ --experiment diabetes_readmission ``` -------------------------------- ### Fetch Dataset as PyTorch DataLoader Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Load the training set of a fetched TableShift dataset as a PyTorch DataLoader. This allows for batch processing of data during model training. ```python # Fetch and use a pytorch DataLoader train_loader = dset.get_dataloader("train", batch_size=1024) for X, y, _, _ in train_loader: ... ``` -------------------------------- ### Caching Datasets with TableShift Source: https://github.com/mlfoundations/tableshift/blob/main/benchmarking_guide.md Cache preprocessed datasets to sharded files for faster loading. Use `to_sharded` to specify shard size and file type. Cached datasets can be loaded using `use_cached=True`. ```python dset = get_dataset(experiment, cache_dir) dset.to_sharded(rows_per_shard=4096, file_type="csv") ``` ```python dset = get_dataset(experiment, cache_dir, use_cached=True) ``` -------------------------------- ### Train and Evaluate Scikit-learn Model with TableShift Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Load a dataset, train a Gradient Boosting Classifier, and evaluate its accuracy on different splits. Ensure the 'diabetes_readmission' dataset is available. ```python from tableshift import get_dataset from sklearn.ensemble import GradientBoostingClassifier dset = get_dataset("diabetes_readmission") X_train, y_train, _, _ = dset.get_pandas("train") # Train estimator = GradientBoostingClassifier() trained_estimator = estimator.fit(X_train, y_train) # Test for split in ('id_test', 'ood_test'): X, y, _, _ = dset.get_pandas(split) preds = estimator.predict(X) acc = (preds == y).mean() print(f'accuracy on split {split} is: {acc:.3f}') ``` -------------------------------- ### Fetch Dataset as Pandas DataFrame Source: https://github.com/mlfoundations/tableshift/blob/main/README.md Load the training set of a fetched TableShift dataset as a Pandas DataFrame. The function returns training and testing features and labels. ```python # Fetch a pandas DataFrame of the training set X_tr, y_tr, _, _ = dset.get_pandas("train") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.