Skip to main content

A streamlined approach to model card generation for machine learning models

Reason this release was yanked:

missing package data

Project description

Model Card Printer :printer: :card_index:

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.

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

Installation :hammer_and_wrench:

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

pip install model-card-printer

Quickstart :page_facing_up:

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 Output

demo model card img

Model Card Export Formats :file_folder:

  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 :card_index:

  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 :books:

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

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

model_card_printer-0.1.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

model_card_printer-0.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file model_card_printer-0.1.0.tar.gz.

File metadata

  • Download URL: model_card_printer-0.1.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for model_card_printer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 77440eeefd1d96eead401c2935feeeb4135026ebd59877fa2e3121dc2d969df1
MD5 00ee42b9c633b2f55a3bd030b67aa572
BLAKE2b-256 6d909ea993ce47ba2153f0a69932a98d8084972e6019f0f94fe22d9a6d790599

See more details on using hashes here.

File details

Details for the file model_card_printer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for model_card_printer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15f546c73d73696136913c8c1cb6d429b83c33e2846e63a2f593fd1fb5f9238b
MD5 5b51092cd0d43cbb465a636fe371e25a
BLAKE2b-256 27ecf06ce3004b7c26091f5129362858cbc899fae81781d4085202e61fe186c7

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