Skip to main content

Logic Scoring of Preference - interpretable multi-criteria aggregation

Project description

LogicScore Core

LogicScore Core is a focused Python library for Logic Scoring of Preference (LSP): it provides deterministic, interpretable tree-based aggregation math and companion utilities for suitability mapping, validation, sensitivity analysis, and traversal.

Install

pip install logicscore-core
uv add logicscore-core

Quickstart

from logicscore.core import TreeNode, compute_tree, SuitabilityCurve, validate_tree

# Map raw signals to suitability in [0.0, 1.0].
temperature_curve = SuitabilityCurve.linear((0.0, 100.0), low_suitability=0.0, high_suitability=1.0)
volatility_curve = SuitabilityCurve.inverted_u(peak=20.0, width=20.0, peak_suitability=1.0, base_suitability=0.2)

temperature = TreeNode(
    id="temperature",
    name="Temperature",
    weight=0.6,
    score=temperature_curve(72.0),
)
volatility = TreeNode(
    id="volatility",
    name="Volatility",
    weight=0.4,
    score=volatility_curve(18.0),
)

root = TreeNode(
    id="market_quality",
    name="Market Quality",
    operator=0.5,  # canonical neutral UGCD operator
    children=[temperature, volatility],
)

validation = validate_tree(root)
if not validation.valid:
    raise ValueError(f"invalid tree: {validation.errors}")

score = compute_tree(root)
print(f"Final score: {score:.4f}")

What this package is / is not

In scope

  • Core tree math and utilities (TreeNode, UGCD aggregation, validation, sensitivity, traversal)
  • Deterministic score computation from already-prepared node inputs

Out of scope

  • Runtime decision labels or score-to-action mapping
  • Clock/timestamp enforcement and staleness orchestration
  • Policy orchestration and execution/runtime adapters

For boundary details, see runtime-boundary.md.

API surface

Canonical imports are from logicscore.core:

  • TreeNode
  • compute_tree
  • SuitabilityCurve
  • validate_tree, ValidationResult
  • compute_sensitivity
  • get_all_leaves, get_all_nodes

Development

uv sync --extra dev
uv run ruff check logicscore/ tests/
uv run mypy logicscore/
uv run pytest

If your environment does not expose script entry points through uv run, use:

uv run --extra dev python -m mypy logicscore/
uv run --extra dev python -m pytest

Release Validation

uv run ruff check logicscore/ tests/
uv run mypy logicscore/
uv run pytest
uv build
uv run twine check dist/*

License

Licensed under the MIT License. See LICENSE.

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

logicscore_core-0.1.0.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

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

logicscore_core-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logicscore_core-0.1.0.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for logicscore_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a532add2b681e3c119eac3f1e199a3d52a27d7bc34cfb549e8120752f3722f28
MD5 17d314edb732cb8880d2e7bcbb4cf4b0
BLAKE2b-256 e773909aa0953d2dc6dc6682e5d3e0ee1d03902ac540f03f8d30416bb1f755da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: logicscore_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for logicscore_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da9d54a32b8f619f5d1062de2cc2681154d713bfc08acdbda7f01475ef49aba9
MD5 9ca7d0c5812a8a10dc3f4856afeeb301
BLAKE2b-256 5fb9551631867ac7e08cce1c060a80afa7dac827891ce3559832a1c891b1b677

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