Skip to main content

A Python library for generating and simplifying fuzzy linguistic summaries of data.

Project description

FuzzyLinguistics

PyPI version License

A powerful and flexible Python library for generating and simplifying fuzzy linguistic summaries of data. Turn complex datasets into human-readable, natural language insights.

This library implements a complete system for creating summaries of one or two datasets (e.g., comparing models), evaluating their truth and quality, and simplifying them from thousands of potential statements into a handful of concise, meaningful insights.

Key Features

  • Generate Summaries: Create summaries for single datasets or compare two datasets against each other.
  • Flexible Configuration: Define your linguistic variables programmatically in Python or through a clean JSON interface.
  • Powerful Simplification: A multi-stage graph-based algorithm prunes and combines thousands of raw statements into a coherent, high-level summary.
  • Quality Metrics: Evaluates summaries based on truth, focus, simplicity, and relevance.
  • Visualization: Includes tools to plot membership functions and export the summary graph for analysis.

Installation

Install fuzzylinguistics directly from PyPI:

pip install fuzzylinguistics

Quick Start

The easiest way to get started is with a JSON configuration file.

1. Create your configuration file (config.json)

This file defines your data, linguistic variables (summarizers, qualifiers), and quantifiers.

{
    "datasets": [
        {
            "category_name": "Cars",
            "model_name": "Car Example",
            "uses_qualifier": true,
            "input_dimension_labels": ["color"],
            "input_dimension_units": [null],
            "input_data": [
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [1]
            ],
            "output_dimension_labels": ["speed"],
            "output_dimension_units": [null],
            "output_data": [
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [0],
                [1]
            ]
        }
    ],
    "summarizers": [
        {
            "dimension_name": "color",
            "predicates": ["Red", "Green", "Blue"],
            "trapezoidal_x_vals": [
                [0, 0, 0, 0],
                [0.5, 0.5, 0.5, 0.5],
                [1, 1, 1, 1]
            ],
            "relevancy_weights": [1, 1, 1]
        }
    ],
    "qualifiers": [
        {
            "dimension_name": "speed",
            "predicates": ["Slow", "Normal", "Fast"],
            "trapezoidal_x_vals": [
                [0, 0, 0, 0],
                [0.5, 0.5, 0.5, 0.5],
                [1, 1, 1, 1]
            ],
            "relevancy_weights": [1, 1, 1]
        }
    ],
    "quantifiers": {
        "dimension_name": "quantifier",
        "predicates": ["None", "None", "A Few", "Some", "Many", "All"],
        "trapezoidal_x_vals": [
            [null, null, null, null],
            [0, 0, 0, 0],
            [0.00001, 0.00001, 0.00001, 0.5],
            [0.0, 0.5, 0.5, 0.99999],
            [0.5, 0.99999, 0.99999, 0.99999],
            [1, 1, 1, 1]
        ],
        "relevancy_weights": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
    }
}

2. Run the summarization in Python

# main.py
from fuzzylinguistics import setup_fls

# 1. Setup the system from the config file
fls = setup_fls(config_json_path="config.json")

# 2. Generate and simplify the summary
# Results will be saved to the specified directory
fls.generate_fls_one_model(results_dir='./car_summary_results')

# 3. Print the final, simplified summary
print("--- Final Simplified Summary ---")
for statement in fls.results["simplified_stage_4_summary"]:
    print(statement)

Example Output:

--- Final Simplified Summary ---
None are green color or normal speed.
Of the cars with blue color none are slow speed, and all are fast speed.
Of the cars with red color none are fast speed, and all are slow speed.

Examples

For more detailed examples, including how to compare two models and how to set up the system programmatically without JSON, please see the /examples directory in the project repository.

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

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

fuzzylinguistics-0.2.2.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

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

fuzzylinguistics-0.2.2-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file fuzzylinguistics-0.2.2.tar.gz.

File metadata

  • Download URL: fuzzylinguistics-0.2.2.tar.gz
  • Upload date:
  • Size: 55.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fuzzylinguistics-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9c6aa60f7f025c95511ec814cde99b637046ee65fe91826d00b3d05437e1b4c3
MD5 74a409fb36b7eaa10849b0ba00f25567
BLAKE2b-256 0328a86d8ea74e91e8994ef2f1d78906b6368a0b7c4e547cf584d69c8f834a00

See more details on using hashes here.

Provenance

The following attestation bundles were made for fuzzylinguistics-0.2.2.tar.gz:

Publisher: publish.yml on lyvelyte/fuzzylinguistics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fuzzylinguistics-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fuzzylinguistics-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 562f4c6b722bf8397b6b5f445d303a344f246334efbd35c4336be0430086a699
MD5 7bb5d64a447d72f1b6bd4a7abd097fb8
BLAKE2b-256 fac2b6b6fbf49b844ee15590c9a49363f8c9efd4b9245dc5d3853f69589dbc0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fuzzylinguistics-0.2.2-py3-none-any.whl:

Publisher: publish.yml on lyvelyte/fuzzylinguistics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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