AICard-Eval
This is a package created under the AI-CODE and it's part of the transparency services for AI model cards. Its purpose is to provide a single tool for evaluating AI models with performance and bias metrics. The output is standardized and meant (but not restricted) to be used as an import for aicard package.
⚡ Quickstart
To install use:
conda create -n aicard-eval python=3.11
conta activate aicard-eval
pip install aicard-eval
or if you clone this repo
pip install -e .
Follow the script bellow. The aicard-eval will choose the correct metrics corresponding to your case. For more examples see the examples/ folder.
You can use datasets and models from service providers e.g. huggingface or you can use your local models and datasets. Supported datasets types are: .csv, .tsv, .json, .jsonl, .xml, .yml, .yaml, .parquet, .feather, .pickle and supported image types are .jpg, .jpeg, .png, .gif, .bmp, .tiff, .tif
import aicard_eval
from datasets import load_dataset
from transformers import pipeline
# 1) Load your model
classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
# 2) Load your dataset
dataset = load_dataset("google-research-datasets/go_emotions", split='test')
class_names = dataset.features["labels"].feature.names
# 3) Define a function to handle the dataset
def pipeline(data):
sentences = [text for text in data['text']]
model_outputs = classifier(sentences)
out = []
for sample in model_outputs:
flat = {d['label']: d['score'] for d in sample}
out.append([flat[name] for name in class_names])
return out
# 4) call the aicard-eval evaluate function
metrics = aicard_eval.evaluate(
data=dataset,
pipeline=pipeline,
task=aicard_eval.tasks.nlp.text_classification,
batch_size=32)
print(metrics)
# {'batch_size': 32,
# 'cpu_model': 'AMD Ryzen 7 7800X3D 8-Core Processor',
# 'date': '2026-May-14',
# 'datetime': '2026-May-14 18:19',
# 'emissions': '208.987 mg',
# 'energy_consumption': '620.925 mWh',
# 'execution_time': 'inference: 30.62s, metrics: 66.70ms',
# 'gpu_model': '1 x NVIDIA GeForce RTX 4070 SUPER',
# 'metrics': {'auc_roc_macro': 0.929,
# 'auc_roc_weighted': 0.91,
# 'f1_macro': 0.466,
# 'f1_micro': 0.574,
# 'max_dfnr': 0.201,
# 'max_dfpr': 0.034,
# 'min_prule': 0.655,
# 'precision_macro': 0.509,
# 'precision_micro': 0.574,
# 'recall_macro': 0.465,
# 'recall_micro': 0.574,
# 'top1_acc_macro': 0.574,
# 'top1_acc_micro': 0.574,
# 'top1_acc_weighted': 0.574},
# 'num_classes': 28,
# 'package_version': '0.1.4',
# 'ram_total_size': 15.621414184570312,
# 'task': 'Text Classification'}
You can also upload your metrics to our model card database. This will create an html formated report of your inference run and store it in your own model card.
from aicard_eval.utils import upload
upload(username = USER_NAME, password = PASSWORD, metrics = metrics, card_id = 116)
💡 Pipeline Instructions
The pipeline funtion is the inference loop that the evaluate function calls to generate the predictions of the model. It is completely abstract which means it can contain whatever the user wants. There are only two rules to follow to construct the pipeline:
- It must have a single function parameter
def pipeline(data) - It must return a specific format depending on the task.
The package supports several formats for each task but until they are thoroughly tested here is a list you can follow:
| Task | Return Format | Example |
|---|---|---|
| Binary Classification | list [ int ] | [ 0,1,0,0 ] |
| Multi-class Classification | list[ list[ float ] ] | [ [0.654, 0.125, 0.471], [0.268, 0.659, 0.073]] |
| Multi-label Classification | list[ list[ int ] ] | [ [ 2 ],[ 9,3 ],[ 3,0,1 ],[ 0 ] ] |
| Object Detection | list[ dict ] | [{ "boxes": [ [ 25, 27, 37, 54 ], [ 119, 111, 40, 67 ] ], "labels": [ 0, 1 ], "scores": [ .88, .70 ] }, { "boxes": [ [ 64, 111, 64, 58 ] ], "labels": [ 0 ], "scores": [ .71 ]` }] |
On the other hand data is basically the dataset the user imported split into batches of size batch_size. A loop will call the pipeline function until all batches are processed by it. The data is a dictionary of lists dict[str, list]. For example if we import a .csv:
name, age
Alice, 30
Bob, 25
Charlie, 35
with batch_size=3 then
>>> data['name']
['Alice', 'Bob', 'Charlie']
>>> data['age'][0]
30
Metadata
Release files for aicard-eval 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aicard_eval-0.1.4.tar.gz | 18.7 kB | Without provenance | Details for aicard_eval-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aicard_eval-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for aicard_eval-0.1.4-py3-none-any.whl |
Total release size: 38.4 kB
Release files / aicard_eval-0.1.4.tar.gz
| Download URL | aicard_eval-0.1.4.tar.gz |
|---|---|
| Size | 18.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8f7f3ed8a8466df440a408a815451eb9765feb1008045a44b5006bae7657a72
|
|
BLAKE2b-256 checksum How to use checksums |
c77c6d6efebbf0a6323c752803817e56916a334376e6e593490fec0f5175de86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / aicard_eval-0.1.4-py3-none-any.whl
| Download URL | aicard_eval-0.1.4-py3-none-any.whl |
|---|---|
| Size | 19.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
881acdcafa217b5d689cc817c492a9540c3ded0b9605cfd09add3916b5f1d5cb
|
|
BLAKE2b-256 checksum How to use checksums |
d6110cd6dfa9fca3e0192e23047eb287ba5a49d032b3f4bdae26f611b2ae702d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for aicard-eval 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.