Skip to main content

HyperFast: Instant Classification for Tabular Data

Project description

HyperFast : Instant Classification for Tabular Data

HyperFast is a hypernetwork designed for fast classification of tabular data, capable of scaling to large datasets. Utilizing a meta-trained hypernetwork, HyperFast generates a dataset-specific target network in a single forward pass, eliminating the need for time-consuming model training.

Installation

HyperFast can be installed from PyPI using

pip install hyperfast

This package contains example code to run HyperFast. Ensure that you are using Python 3.9 or later to run this project. When using HyperFast for the first time, the model weights will be downloaded automatically. The model weights are also available here.

Usage

Here's a quick example on how to use HyperFast's scikit-learn-like interface:

import torch
import numpy as np
from hyperfast import HyperFastClassifier
from sklearn.metrics import accuracy_score

# Load your dataset
X_train, y_train = np.load("data/hapmap1_X_train.npy"), np.load( "data/hapmap1_y_train.npy")
X_test, y_test = np.load("data/hapmap1_X_test.npy"), np.load("data/hapmap1_y_test.npy")

# Set the device
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')

# Initialize HyperFast
model = HyperFastClassifier(device=device)

# Generate a target network and make predictions
model.fit(X_train, y_train)
predictions = model.predict(X_test)

accuracy = accuracy_score(y_test, predictions)
print(f"Accuracy: {accuracy * 100:.2f}%")

Warning:

  • Set cat_features as the list of indices of the categorical features in the dataset (if any), now in __init__.
  • The current default hyperparameters provide medium speed-accuracy performance.
  • :rocket: For the fastest inference (but less accurate) set n_ensemble=1 and optimization=None.
  • :bar_chart: If you are dealing with an imbalanced dataset, consider setting stratify_sampling=True with n_ensemble > 1.
  • :globe_with_meridians: If you are dealing with a very high-dimensional dataset (e.g., >3000 features), consider setting feature_bagging=True with n_ensemble > 1.
  • :ok_hand: For slower but most accurate predictions, optimize the inference parameters of HyperFast for each dataset. In this case, we recommend the following search space:
param_grid = {
    'n_ensemble': [1, 4, 8, 16, 32],
    'batch_size': [1024, 2048],
    'nn_bias': [True, False],
    'stratify_sampling': [True, False],
    'optimization': [None, 'optimize', 'ensemble_optimize'],
    'optimize_steps': [1, 4, 8, 16, 32, 64, 128],
    'seed': list(range(10))
}

License

This project is under the CC BY-NC 4.0 license. See LICENSE for details.

Cite us

If you use HyperFast in your research, please cite our paper:

@inproceedings{bonet2024hyperfast,
  title={HyperFast: Instant Classification for Tabular Data},
  author={Bonet, David and Montserrat, Daniel Mas and Gir{\'o}-i-Nieto, Xavier and Ioannidis, Alexander},
  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
  year={2024}
}

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

hyperfast-1.0.6.tar.gz (230.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperfast-1.0.6-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file hyperfast-1.0.6.tar.gz.

File metadata

  • Download URL: hyperfast-1.0.6.tar.gz
  • Upload date:
  • Size: 230.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.1

File hashes

Hashes for hyperfast-1.0.6.tar.gz
Algorithm Hash digest
SHA256 05be2ac8f9ca56c5a32a3e23d2c99d2ed7cf5780fb722056d2448033ae24fdcb
MD5 09b549054c601f880ea9d1e769917b61
BLAKE2b-256 3bdc56c5f8ec623c24e55127b4ff6a9dca2dfe5e035dcc9b5442b0f849687d6a

See more details on using hashes here.

File details

Details for the file hyperfast-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: hyperfast-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.1

File hashes

Hashes for hyperfast-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 aedd552bb6c98ed71673418f959a2850e5cec64ba8e647fb049195fd9e9518af
MD5 08fa0a563f40c3c11e223810ab503aa6
BLAKE2b-256 2919fff9dbb6b9078f4f0343e3e4940d1bd812131f4d7b70b7a3d62ad16367c7

See more details on using hashes here.

Supported by

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