setqca
A native, typed Python implementation of Qualitative Comparative Analysis (QCA).
setqca is not an R wrapper. It provides an auditable Python implementation of
the mathematical core of crisp-set and fuzzy-set QCA, with exact Boolean
minimisation and data-science-friendly result objects.
Status: 0.1.0 alpha. Conservative and parsimonious csQCA/fsQCA are the stable focus. Directional intermediate solutions are deliberately marked experimental until parity-tested against the reference R
QCAimplementation.
📖 Documentation · 🚀 Getting started · 🔬 Validation policy
Why this project
The mature R QCA ecosystem supports crisp-set, fuzzy-set, multi-value and
temporal QCA with exact Boolean minimisation. Python has individual QCA-related
projects, but there is still room for a general-purpose, typed and thoroughly
validated scientific implementation that lives natively in the Python data
stack.
Four commitments shape the design:
| Commitment | What it means in practice |
|---|---|
| Exact, not heuristic | Classical Quine-McCluskey with branch-and-bound solution of the prime-implicant chart. All tied minimal covers are returned, not an arbitrary one. |
| Explicit, not implicit | Every threshold is a named parameter. Ambiguous input — a membership of exactly 0.5, an uncalibrated column — raises instead of being silently resolved. |
| Typed end to end | Ships py.typed; passes mypy --strict; 100% test coverage enforced in CI. |
| Honest about maturity | Features short of parity with R QCA are marked experimental rather than quietly approximated. |
Features
- crisp calibration
- three-anchor direct fuzzy calibration
- logistic (numerically stable across the whole real line)
- piecewise linear/power
- increasing and decreasing sets
- typed set algebra with
&,|and~ - sufficiency consistency, coverage and PRI
- necessity consistency, coverage and RoN
- complete binary truth tables
- frequency, consistency and PRI cutoffs
- contradiction and logical-remainder classification
- exact classical Quine-McCluskey prime-implicant generation
- exact branch-and-bound solution of the prime-implicant chart
- conservative solutions
- parsimonious solutions
- experimental directional intermediate solutions
- tidy pandas exports
- optional parity harness against R
QCA
Installation
pip install setqca
Requires Python 3.11+. Runtime dependencies are numpy and pandas only.
For a development checkout:
git clone https://github.com/DiogoRibeiro7/setqca-python.git
cd setqca-python
poetry install
Usage
Calibration
from setqca import calibrate_direct
innovation = calibrate_direct(
raw_innovation,
full_out=10,
crossover=50,
full_in=90,
)
The default idm=0.95 maps the three anchors to approximately 0.05, 0.5 and
0.95 for increasing sets.
Typed fuzzy-set algebra
from setqca import Condition
A = Condition("A")
B = Condition("B")
C = Condition("C")
configuration = A & B & ~C
membership = configuration.evaluate(data)
fsQCA
from setqca import FSQCA
model = FSQCA(
consistency=0.85,
pri=0.70,
frequency=2,
)
result = model.fit(
data,
outcome="Y",
conditions=["A", "B", "C", "D"],
case_id="case",
)
print(result)
print(result.truth_table.to_frame())
print(result.summary_frame("parsimonious"))
csQCA
from setqca import CSQCA
result = CSQCA().fit(
crisp_data,
outcome="Y",
conditions=["A", "B", "C"],
)
CSQCA rejects non-binary condition or outcome columns.
Exact minimisation
The low-level engine is public for testing and research:
from setqca.minimize import minimize
# AB~C + ABC -> AB
solutions = minimize({6, 7}, width=3)
print(solutions[0].as_expression(("A", "B", "C")))
# A*B
Logical remainders are explicit don't-cares:
solutions = minimize(
{6, 7},
dont_cares={4, 5},
width=3,
)
Scientific validation policy
The R QCA package is used as a reference implementation for parity tests,
not as a runtime dependency. The repository includes validation/r/parity.R so
canonical datasets can be run through both implementations.
Correctness rests on five layers: unit tests against known results, brute-force
exactness tests of the minimiser, property-based invariant tests, error-contract
tests, and R parity fixtures. See
the validation page
for the current parity status of each component, and
docs/METHODOLOGY.md for the formal implementation
contract.
Non-goals for 0.1
- claiming complete parity with R
QCA; - mvQCA;
- tQCA;
- CCubes/eQMC performance parity;
- stable standard intermediate solutions.
These are roadmap items rather than hidden approximations. See
docs/ROADMAP.md.
Development
poetry install --with dev,docs
poetry run pre-commit install
make check # lint, format, types and tests
make docs # serve the documentation locally
Without make:
poetry run ruff check .
poetry run ruff format --check .
poetry run mypy
poetry run pytest --cov=setqca
Contributions are welcome — please read CONTRIBUTING.md first, particularly the scientific-correctness requirements for changes to the mathematical core.
Citing
If you use setqca in published research, please cite the archived release.
Machine-readable metadata is provided in CITATION.cff,
codemeta.json and .zenodo.json.
License
MIT — see LICENSE.
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 setqca-0.1.0.tar.gz.
File metadata
- Download URL: setqca-0.1.0.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
374871030a3d806cfe57c66934bfa043978c4c5838423c450a964bc34c505cf0
|
|
| MD5 |
a50eaf4d8482254de9b5c7d4ad7b0d1e
|
|
| BLAKE2b-256 |
0f89d48c9043ea1e14a617207aa5f74c5006a82ae9be498aee553273615bf466
|
Provenance
The following attestation bundles were made for setqca-0.1.0.tar.gz:
Publisher:
release.yml on DiogoRibeiro7/setqca-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setqca-0.1.0.tar.gz -
Subject digest:
374871030a3d806cfe57c66934bfa043978c4c5838423c450a964bc34c505cf0 - Sigstore transparency entry: 2412552571
- Sigstore integration time:
-
Permalink:
DiogoRibeiro7/setqca-python@beb48a1e5d9c40bba2d40f9cb8d9559c3471b444 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DiogoRibeiro7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@beb48a1e5d9c40bba2d40f9cb8d9559c3471b444 -
Trigger Event:
push
-
Statement type:
File details
Details for the file setqca-0.1.0-py3-none-any.whl.
File metadata
- Download URL: setqca-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b1a61f0dd7163ca133a952d0c94713b65b14ba1e92892f6fdcfe5a25ee58632
|
|
| MD5 |
01859e408463143685edbe0a0675f759
|
|
| BLAKE2b-256 |
fb5b9a651f088c4a2b620ce9a62769bf0c812903602d53d28d4a5ecb7f7be2ba
|
Provenance
The following attestation bundles were made for setqca-0.1.0-py3-none-any.whl:
Publisher:
release.yml on DiogoRibeiro7/setqca-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setqca-0.1.0-py3-none-any.whl -
Subject digest:
0b1a61f0dd7163ca133a952d0c94713b65b14ba1e92892f6fdcfe5a25ee58632 - Sigstore transparency entry: 2412552695
- Sigstore integration time:
-
Permalink:
DiogoRibeiro7/setqca-python@beb48a1e5d9c40bba2d40f9cb8d9559c3471b444 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DiogoRibeiro7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@beb48a1e5d9c40bba2d40f9cb8d9559c3471b444 -
Trigger Event:
push
-
Statement type: