Skip to main content

_Catasta_ is a Python library designed to simplify the process of Machine Learning model experimentation. Optimization, training, evaluation and inference all in one place!

Project description

catasta: straightforward machine learning model experimentation

pypi version MIT License

catasta is a python library designed to simplify the process of machine learning model experimentation. optimization, training, evaluation and inference all in one place!

[!WARNING] :construction: catasta is in early development :construction:

expect breaking changes on every release until v1.0.0 is reached.

the documentation is under development.


With catasta, you can build a model like an archway... let me explain:

optimization

first, set the foundations of the model with the Foundation class. this class uses the popular and supercool optuna library to optimize a model given a hyperparameter space and an objective function.

hp_space = {
    "n_patches": (2, 7),
    "d_model": (8, 16),
    "n_layers": (1, 2),
    "n_heads": (1, 2),
    "feedforward_dim": (8, 16),
    "head_dim": (4, 8),
    "dropout": (0.0, 0.5),
    "layer_norm": (True, False),
}

foundation = Foundation(
    hyperparameter_space=hp_space,
    objective_function=objective,
    sampler="bogp",
    n_trials=100,
    direction="maximize",
    use_secretary=True,
    catch_exceptions=True,
)

optimization_info = foundation.optimize()

training

set the scaffolds of your model with the Scaffold class. this class integrates a model and a dataset for training and evaluation.

model = FeedforwardRegressor(
    n_inputs=32,
    n_outputs=1,
    hidden_dims=[8, 16, 8],
    dropout=0.0,
    use_layer_norm=True,
    activation="relu",
)

dataset = CatastaDataset(
    root="path/to/dataset/",
    task="regression",
    input_name="input",
    output_name="output",
)

scaffold = Scaffold(
    model=model,
    dataset=dataset,
    optimizer="adamw",
    loss_function="mse",
)

scaffold.train(
    epochs=100,
    batch_size=256,
    lr=1e-3,
)

info = scaffold.evaluate()

inference

your archway is finished with the Archway class. this class runs the inference of the model given its saved path

archway = Archway(
    path= "path/to/saved/model.pt",
)

example_input = np.random.rand(1, 4).astype(np.float32)
output = archway.predict(example_input)

the archway uses the onnxruntime library if a .onnx file is provided, but you must install manually onnx and onnxruntime to use this feature

archway = Archway(
    path= "path/to/saved/model.onnx",
)

example_input = np.random.rand(1, 4).astype(np.float32)
output = archway.predict(example_input)

finally, the archway can also serve a model as a REST API using the FastAPI library. to use this feature, you must install fastapi, pydantic, and uvicorn manually

archway = Archway(
    path= "path/to/saved/model.pt",
)

class Data(BaseModel):
    s0: float
    s1: float
    s2: float
    s3: float

archway.serve(
    host="145.94.127.212",
    port=8080,
    pydantic_model=Data,
)

other modules

catasta also has different modules that facilitate model experimentation

  • catasta.models offers a variety of pre-implemented Machine Learning models. All models are single-scripted, so feel free to copy and paste them anywhere.

  • catasta.transformations let's you apply transformations to the data when its loaded to a dataset, such as window sliding, normalization...

  • catasta.utils has several functions that are useful for model optimization and training.

installation

Install via pip

catasta is available as a PyPi package:

pip install catasta

Install from source

Clone the repository

git clone https://github.com/vistormu/catasta

and install the dependencies

pip install -r requirements.txt

documentation

the documentation is under development, but you can check out some examples in the examples folder!

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

catasta-0.5.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

catasta-0.5.0-py3-none-any.whl (58.7 kB view details)

Uploaded Python 3

File details

Details for the file catasta-0.5.0.tar.gz.

File metadata

  • Download URL: catasta-0.5.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for catasta-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4aa3adfc604be9e0f5a4139df9297c4494bb1e1192532956c872c3f5e190855b
MD5 e059e084ba5c22b0efb9a7d77059f74f
BLAKE2b-256 f7b30be64305304585bd1c81fdb1dd3404495f4c839fe2bf08640e602692bc70

See more details on using hashes here.

File details

Details for the file catasta-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: catasta-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 58.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for catasta-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ea9382cc4755859ca6db5202cb35cea5f1d2415f8be3df2a29752a96792f86d
MD5 ce1cbd5c705f0650349da9a2adc7adca
BLAKE2b-256 8512f05df5201afa7796a9bc7efd76996cc518d8d5e479f6d6998c3d842f97f2

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