Skip to main content

No project description provided

Project description

Explingo

Explingo

Transform your ML explanations into human-friendly natural-language narratives.

NOTE: Explingo is still under active development and currently only supports a few basic explanation types and GPT-API models.

Installation

Explingo can be installed through PIP

pip install explingo

Usage

To transform explanations into narratives, you can use the Narrator class.

from explingo import Narrator, Grader 

example_narratives = [
    ("(Above ground living area square feet, 1256.00, -12527.46), (Overall material and finish of the house, 5.00, -10743.76), (Second floor square feet, 0.00, -10142.29)", 
     "The house's living area size of around 1,200 sq. ft., lower quality materials (5/10), and lack of a second floor are the main reasons for the low price."),
    ("(Second floor square feet, 854.00, 12757.84), (Original construction date, 2003.00, 9115.72)",
     "The house's large second floor of around 850 sq. ft and recent construction date of 2003 increases its value."),
    ("(Overall material and finish of the house, 8.00, 10743.76), (Above ground living area square feet, 2000.00, 12527.46), (Second floor square feet, 1000.00, 10142.29)",
        "The house's high quality materials (8/10), large living area size of around 2,000 sq. ft., and a second floor of around 1,000 sq. ft. are the main reasons for the high price."),
]

explanation_format = "(feature name, feature value, SHAP feature contribution)"
context = "The model predicts house prices"

narrator = Narrator(openai_api_key=[OPENAI_API_KEY], 
                    explanation_format=explanation_format,
                    context=context,
                    labeled_train_data=example_narratives)

explanation = "(number of bathrooms, 3, 7020), (number of bedrooms, 4, 12903)"

narrative = narrator.narrate(explanation)

To evaluate the quality of the generated narratives, you can use the Grader class.

grader = Grader(openai_api_key=[OPENAI_API_KEY], 
                metrics="all", 
                sample_narratives=[narrative[1] for narrative in example_narratives])

metrics = grader(explanation=explanation, 
                 explanation_format=explanation_format, 
                 narrative=narrative)

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

explingo-0.1.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

explingo-0.1.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file explingo-0.1.1.tar.gz.

File metadata

  • Download URL: explingo-0.1.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for explingo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7fb4c7866029e9476c471e11c2f4ea7baba0ce6a39ed25d1c22bfb722242c70e
MD5 3dda4ee97fb5edfe3e60de0b15f1fe63
BLAKE2b-256 e108366082c46abe0a1e7b9a7bfd13e686211d29291dc96d4848f435c001bc34

See more details on using hashes here.

File details

Details for the file explingo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: explingo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for explingo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e10573ae04fa569787461564706c4ed080b3d7c387ee8061d1796ece3f18c9cb
MD5 d1fc73c281cb6d6fc256b3e4b04a4535
BLAKE2b-256 310eba67a2e6347efa81be860613aa376654f0d0f166ccff324d07d47f4c64ce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page