Skip to main content

Foundation data structures and interfaces for the MCDA Python ecosystem

Project description

mcda-core

Foundation library for the MCDA Python ecosystem. Provides the shared data structures, abstract interfaces, and data transformations that all other libraries in the ecosystem build on.

Installation

pip install mcda-core

Python ≥ 3.9, NumPy ≥ 1.25, pandas ≥ 2.0.

Quick start

import numpy as np
import pandas as pd
from mcda_core import PerformanceTable, minmax, zscore

# Build a performance table from raw values
table = PerformanceTable(
    values=np.array([
        [80.0, 20.0, 10.0],
        [65.0, 35.0, 18.0],
        [90.0, 15.0, 14.0],
    ]),
    alternatives=["A", "B", "C"],
    criteria=["cost", "quality", "CO2"],
    directions=[-1, 1, -1],  # minimise cost and CO2, maximise quality
)

# Or load from a CSV
df = pd.read_csv("data.csv", index_col="alternative")
table = PerformanceTable.from_dataframe(df, directions=[-1, 1, -1])

# Normalise — returns a new (immutable) PerformanceTable
norm = minmax(table)

# Convert minimisation criteria to maximisation before passing to a method
table_max = table.as_maximization()

What's included

PerformanceTable

The central data structure — a frozen dataclass wrapping a (n, c) float array of n alternatives × c criteria, together with:

attribute type default
values NDArray shape (n, c) required
alternatives list[str] None
criteria list[str] None
criteria_types list[str] all "cardinal"
directions list[int] all +1 (maximise)

Key methods: from_dataframe(), as_maximization(), to_dataframe(), .shape.

Interfaces

class purpose
MCDAMethod[P] Abstract base for all MCDA methods — requires fit() and result()
MCDAParameters Abstract base for method parameters

KEY_WEIGHTS is the shared string constant for the weights key.

Transformations

All transformations take a PerformanceTable and return a new one (metadata preserved):

function description
minmax(table) (x − min) / (max − min) → [0, 1]
zscore(table) (x − μ) / σ
sum_normalization(table) x / Σx
max_scaling(table) x / max(|x|)
invert_criteria(table) Flip criteria with direction = −1; method: "range" (default) or "sign"
scores_to_ranking(scores) Indices of alternatives sorted best → worst; higher_is_better=True (default)

All table transformations accept an optional criteria argument (list of column indices) to apply the transformation to a subset of criteria.

Ecosystem

This library is the foundation of a modular MCDA ecosystem:

library role repository
mcda-core ← you are here gitlab.ulb.be/smg/mcda-core
promethee PROMETHEE I/II/Gamma/Sort gitlab.ulb.be/smg/promethee
mcda-methods ELECTRE I, MAUT gitlab.ulb.be/smg/mcda-methods
mcda-viz Visualization dashboards (Dash/Plotly) gitlab.ulb.be/smg/mcda-viz

New method libraries only need to depend on mcda-core and inherit from MCDAMethod to be fully compatible with the rest of the ecosystem.

License

MIT — 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

mcda_core-0.3.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

mcda_core-0.3.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file mcda_core-0.3.0.tar.gz.

File metadata

  • Download URL: mcda_core-0.3.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for mcda_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 235d4d573b191d3037f49d4f3ecf47f1f2621ca8e1729d687dcea85b31e8993a
MD5 674dfd45251a3ace54373a7401bd3f05
BLAKE2b-256 3242659ccf9e151a779264239e3e600c8e8262c99c268be16c725619d6fbefa9

See more details on using hashes here.

File details

Details for the file mcda_core-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mcda_core-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for mcda_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5b6c9cac7d676987b13361c96b67e6b55ee68d742978dfaa3f68854034d1d2e
MD5 9bda3c10475c8f6f8802e7b15aaa18ba
BLAKE2b-256 8f6febe11165dfadce248d68c01889676aa3f7aed7eda0cd8e29e8c9972528f0

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