Skip to main content

Model Card Printer

The Model Card Printer simplifies the generation of model cards for machine learning models. Model Card Printer offers a standardized and structured approach to documenting machine learning models, while still providing flexibility for users to customize the document without being overly restrictive.

  • Works with popular data visualization libraries such as Pandas and Plotly.
  • Supports all text-based documentation in Markdown format.
  • Tailor your model card to fit your needs and preferences.
  • Supports exporting model cards in JSON, Pickle, and HTML formats.

Installation

Model Card Printer is available as a PyPI package. Install it using pip package manager:

pip install model-card-printer

Quickstart

1. Create documentation and data visualizations

Note: All visualizations generated here are for demonstration purposes. You could use Pandas to create your visualizations as well.

import plotly.express as px

# Create documentation (markdown format)
documentation_standalone = "# Model Card Demo\nHere is a paragraph related to the documentation.\n## Considerations\nThis demonstration is for anyone that wants to quickly start generating model cards with their trained ML models."

# Create data visualizations and related documentation
df = px.data.tips()
fig1 = px.box(df, y="total_bill")
fig2 = px.histogram(df, x="total_bill", color="sex", marginal="rug",
                         hover_data=df.columns)
fig3 = px.density_heatmap(df, x="total_bill", y="tip")

documentation_for_visuals = "# Quantitative Analysis\nThe visualizations presented are for demonstration purposes only."

# Create standalone data visualizations
df = px.data.iris()
fig_standalone = px.scatter_matrix(df,
    dimensions=["sepal_length", "sepal_width", "petal_length", "petal_width"],
    color="species", symbol="species",
    title="Scatter matrix of iris data set",
    labels={col:col.replace('_', ' ') for col in df.columns})
fig_standalone.update_traces(diagonal_visible=False)

2. Create model card

from model_card_printer import ModelCardPrinter

# Generate an empty model card
model_card = ModelCardPrinter.generate_card()

# Store all the information
model_card.add_custom_documentation(documentation_standalone, document_name = 'demo')
model_card.add_custom_visualization_collection({"demo fig 1": fig1, "demo fig 2": fig2, "demo fig 3": fig3},
                                               documentation = documentation_for_visuals,
                                               collection_name = "Demo visuals and text")
model_card.add_individual_custom_visualization(fig_standalone, "demo standalone fig")

# Save model card as HTML (default dark mode, else add parameter "is_dark_mode = False")
model_card.write_html("demo_model_card.html")

Model Card Export Formats

  1. Output as JSON
# Saving to JSON file
model_card.write_json("model_card.json")

# OPTIONAL: Intermediate output
model_card_json = model_card.to_json()
  1. Output as HTML
# Saving to HTML file
model_card.write_html("model_card.html")

# OPTIONAL: Intermediate output
model_card_html = model_card.to_html()
  1. Output as Pickle object (not recommended unless there is a need to store the datasets inside the model card)
import pickle

with open('model_card.pkl', 'wb') as file:
    pickle.dump(model_card, file)

Model Card Import Formats

  1. Load from JSON file
model_card = ModelCardPrinter(file_path = "model_card.json").load_from_json()
  1. Load from Python dictionary
dict_model_card = previous_model_card.to_dict()
model_card = ModelCardPrinter(data_dict = dict_model_card).load_from_dict()

Tutorials

For more in-depth demonstrations on model-card-printer package, refer to the provided examples.

Metadata

Release files for model-card-printer 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for model-card-printer 0.1.1
File Size Uploaded Provenance Actions
model_card_printer-0.1.1.tar.gz 23.8 kB Without provenance Details for model_card_printer-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for model-card-printer 0.1.1
File Interpreter ABI Platform Actions
model_card_printer-0.1.1-py3-none-any.whl Python 3 none any Details for model_card_printer-0.1.1-py3-none-any.whl

Total release size: 39.7 kB

Release files / model_card_printer-0.1.1.tar.gz

Download URL model_card_printer-0.1.1.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c69204b60e9c74de4ad92d932b005a8d117174d0cfc2b6e983429aeda994ae9b
BLAKE2b-256 checksum
How to use checksums
a021939aee816164df86707f0711e0d6e81131f815bf24108c9c2803c592720f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / model_card_printer-0.1.1-py3-none-any.whl

Download URL model_card_printer-0.1.1-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bdbe60e16f8289c97803b372b8db783dc6281df5c3a09cc8c9f331d01394498
BLAKE2b-256 checksum
How to use checksums
bf4660e6362e6ff2b3978f637e0851ff8ff12f6ff2b08fae76651ade26d55c5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for model-card-printer 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page