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.1.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.1-py3-none-any.whl (58.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: catasta-0.5.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b5dd0a791daddc7b4c96cc67fd4293573b49eb8b57e0697cfbb219b618de8a01
MD5 918d3149b21436f5be9ccd157ca2ac03
BLAKE2b-256 f7ef92e2438e2adc3898b70595443bd8757b15818d8308975e3e1adbd17ce253

See more details on using hashes here.

File details

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

File metadata

  • Download URL: catasta-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 58.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b38582197d1fcf0125042b14e901af9992993e0dbc36f39ca71e8c303d060b5f
MD5 c67e2c14fe50ce6254cb8d554d591ade
BLAKE2b-256 fbc9a7678bc06f52bb6e4b1ca1cc39f77944ebdbdf1e80187db36871280dc4ef

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