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 | formula |
|---|---|
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" |
All functions 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 | methods | 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 |
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcda_core-0.2.1.tar.gz.
File metadata
- Download URL: mcda_core-0.2.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22e159b3114a66b2e62e007c3a1ffe9452faa5112ffa165261bc144445bc916b
|
|
| MD5 |
5fefcf058993052210f1df12f43b0f7a
|
|
| BLAKE2b-256 |
fb7a7b0399010fa68b7925a81dfbe6878ba82f3b5df04d8ad6aa0bbd1129cece
|
File details
Details for the file mcda_core-0.2.1-py3-none-any.whl.
File metadata
- Download URL: mcda_core-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b7c7a8897794e529f048f0df61412ccbde5cd0a88f1ce79b48280950875cf6f
|
|
| MD5 |
0529d334f1a98d609052059f6a66ce76
|
|
| BLAKE2b-256 |
3b54fd0b75f8b7fd597a3b3464cdc655c2d5f59c8ee65c14f5a539f033b0f273
|