Component interfaces of the MAMMOth fairness toolkit.
Project description
MAMMOth-commons
Component interfaces of the MAMMOth fairness toolkit.
This package is in the pre-alpha stage.
How to create a new component
Install the latest version of MAMMOth-commons
in your virtual environment:
pip install --upgrade MAMMOth-commons
You are now ready to write and deploy a MAMMOth component. Follow these steps - you can find examples below:
- Import the necessary dataset or model classes
from the
mammoth.datasets
andmammoth.models
namespace respectively. Use them to annotate your method's argument and return types. Type annotations are mandatory for datasets and models. - You may also add keyword arguments that serve as parameters with default values, which don't require annotation.
- Don't forget to create a docstring for your component.
- Decorate your component with either the
@mammoth.integration.metric(version, python="3.11")
or the@mammoth.integration.loader(version, python="3.11")
decorator. These decorators require at least one argument to denote the component's version. - Create a technical component by running the following
command (to run this, also run
pip install docker
first):
kfp component build . --component-filepattern test.py --no-push-image
Metric decorator
This is how to define a metric component:
from mammoth.datasets import CSV
from mammoth.models import ONNX
from mammoth.exports import Markdown
from typing import Dict, List
from mammoth.integration import metric
@metric(version="v001")
def new_metric(
dataset: CSV,
model: ONNX,
sensitive: List[str],
parameters: Dict[str, any] = None,
) -> Markdown:
"""Write your metric's description here.
"""
return Markdown("these are the results")
Loader decorator
This is how to define a dataset or model loader component:
from mammoth.datasets import CSV
from mammoth.integration import loader
@loader(version="v001", python="3.11")
def data_csv_loader(
path: str,
delimiter: str = ",",
) -> CSV:
"""This is a CSV loader.
"""
# load from path given delimiter or other arguments
return CSV(
... # add arguments here
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for MAMMOth_commons-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d77010665033d991fd7e9394b0a1935249d9ee698aaa69492172d5b7ab19cbe8 |
|
MD5 | 0c800747c5f100b9bea703ae55756c8e |
|
BLAKE2b-256 | 5833d58dce7e1d3d68a5c061c79e0f8aaa64d660e47520edfd4474d07535173e |