This is SPATA
A deterministic method to analyze the statistical patterns of tabular datasets and the decision boundaries of machine learning models.
If you use SPATA, please cite the primary conference paper: https://doi.org/10.1007/978-3-032-19102-1_22
Check out the official documentation: https://spata.readthedocs.io/en/latest
Explore the open source code repository: https://github.com/vitorinojoao/spata
Install it from the Python Package Index: https://pypi.org/project/spata
How it works
The summarization of any tabular dataset or model is provided in a SPATA Card, which defines a domain-independent representation.
Each feature (column) is converted into a set of hierarchical projections, and all the data instances (rows) are aggregated into regions of a discrete space.
It is saved in the following JSON structure:
{
"type": "spata",
"subtype": "card",
"hexdigest": hash of base Card object,
"subhexdigest": hash of base Card object,
"info": {
"name": str,
"timestamp": int,
"granularity": int,
"dtype_optimized": numpy.dtype for "int8" or "int16" or "int32",
"dtype_safe": numpy.dtype for "int8" or "int16" or "int32" or "int64",
"n_features": int,
"n_projections": int,
"n_inverses": int,
"n_regions": int,
},
"features": {
f1: {
"name": str,
"init": "inferred" or "configured",
"type": "continuous" or "discrete" or "categorical",
"dtype": numpy.dtype for any numeric scalar type,
"n_projections": int,
"projection_min": p1,
"projection_max": p2,
},
f2: { ... },
...
},
"projections": {
f1: {
p1: {
"bin_min": float,
"bin_max": float,
"n_inverses": int,
"n_regions": int,
},
p2: { ... },
...
},
f2: {
p1: { ... },
p2: { ... },
...
},
...
},
"regions": {
(p1, p1, ...): {
"n_inverses": int,
},
(p1, p2, ...): { ... },
(p2, p1, ...): { ... },
(p2, p2, ...): { ... },
...
}
}
The analysis of the regions of a tabular dataset is provided in a SPATA Data Card, using its target labels.
The analysis of all the possible regions of a model’s decision boundaries is provided in a SPATA Model Card, using its prediction function.
Since each projection of each feature can have a different effect across each class, independent neutrosophic sets are computed with Truth, Indeterminacy and Falsity values.
New fields are added to the JSON structure:
{
"type": "spata",
"subtype": "datacard" or "modelcard",
"hexdigest": hash of base Card object,
"subhexdigest": hash of DataCard or ModelCard object,
"info": {
"n_classes": int,
"n_generated": int,
...
},
"features": {
f1: {
"truth_min": float,
"truth_max": float,
"indeterminacy_min": float,
"indeterminacy_max": float,
"falsity_min": float,
"falsity_max": float,
...
},
...
},
"classes": {
k1: {
"name": str,
"init": "inferred" or "configured",
"truth_min": float,
"truth_max": float,
"indeterminacy_min": float,
"indeterminacy_max": float,
"falsity_min": float,
"falsity_max": float,
"n_regions": int,
"region_min": (p1, p1, ...),
"region_max": (p2, p2, ...),
"n_inverses": int,
"n_generated": int,
},
k2: { ... },
...
},
"projections": {
f1: {
p1: {
"n_generated": int,
"class_projections": {
k1: {
"truth": float,
"indeterminacy": float,
"falsity": float,
},
k2: { ... },
...
},
...
},
...
},
...
},
"regions": {
(p1, p1, ...): {
"n_generated": int,
"class_regions": {
k1: {
"n_inverses": int,
"n_generated": int,
},
k2: { ... },
...
},
...
},
...
}
}
(Note: “n_generated” fields are only available in a ModelCard)
How to use
This package provides an optimized open-source implementation of SPATA, and an additional Plotter object for interactive visualization:
from spata import Card, Plotter
from spata.data import DataCard
from spata.model import ModelCard
To save and visualize the analysis, you can use the following functions:
# Create a base card with custom granularity for the discrete space
# Using X_train
card = Card(X_train, granularity=3, name="This is SPATA", keep_base=True)
# Analyze the regions of a tabular dataset
# Using y_train
d_card = DataCard(card, y_train, classification=True)
d_json = d_card.save(filepath="d_card.json")
d_summary, d_fig = d_card.summary(plotter=True, features=None, classes=None)
# Analyze all the possible regions of a model's decision boundaries
# Using model_prediction_function
m_card = ModelCard(card, model_prediction_function, classification=True)
m_json = m_card.save(filepath="m_card.json")
m_summary, m_fig = m_card.summary(plotter=True, features=None, classes=None)
To perform synthetic data generation, you can use the following functions:
# Convert new data into the discrete space
# Using X_test
regions = card.convert(X_test)
# Generate only for specific regions
X_test_gen = card.generate(regions, quantity=9, realistic=True)
# Generate across all the possible regions
X_gen = card.generate(card.permutate(), quantity=9, realistic=True)
Metadata
Release files for spata 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spata-0.5.0.tar.gz | 30.7 kB | Without provenance | Details for spata-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spata-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for spata-0.5.0-py3-none-any.whl |
Total release size: 61.9 kB
Release files / spata-0.5.0.tar.gz
| Download URL | spata-0.5.0.tar.gz |
|---|---|
| Size | 30.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fff34d51959704f63c75134ee9ff006651f0156dde7ca9266ac6a6e300158b93
|
|
BLAKE2b-256 checksum How to use checksums |
48056411af3a661712f58c0487e1b6416438604989533d787e798139e654d6e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.5
|
Release files / spata-0.5.0-py3-none-any.whl
| Download URL | spata-0.5.0-py3-none-any.whl |
|---|---|
| Size | 31.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4e4e29051c2b84b442451a50f1f432a28694e6fc2c91de53d07c2a62d0716a9
|
|
BLAKE2b-256 checksum How to use checksums |
9155099ef1d105f01f0e20e993e857bcdfc44555e668cbe326e517e135a529c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.5
|
Security for spata 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.