Resample Exposure Similarity
Resample Exposure similarity is a novel approach to measuring similarity in heterogeneous data based on the frequency of categorical variables and the density distribution of numericals. This library provides a rough implementation of the measure as a class that can compute a similarity matrix. Additional code is included in the repository, for implementing and experimenting with resample exposure similarity and competitors, including functions for calculating similarity matrices, performing nearest neighbour classification, and clustering using partitioning around medoids.
Installation
To install the library, run the following command:
pip install rex-score
Tutorial
import seaborn as sns
from rex_score import ResampleExposure
df = sns.load_dataset('penguins')
df_train, df_test = df.iloc[:300], df.iloc[300:]
# Create an instance of the ResampleExposure class
# categorical features need not be specified, and will be automatically inferred
rex = ResampleExposure(target_distribution=df_train.dropna(),
categorical_features=['species', 'island'],
unique_threshold=5,
feature_weights=None,
)
# single point comparison
similarity = rex.resample_exposure_sim(query_point=df_test.iloc[0],
target_point=df_train.iloc[0],
normalised=True
)
# similarity matrix
similarity_matrix = rex.resample_exposure_matrix(query_df=df_test,
normalised = False,
reverse_direction = False,
overwrite_memory = False,
n_jobs = -1
)
For the calculation of the similarity matrix, if no arguments are given it will return the similarity matrix of the target distribution with itself. Reverse direction is to use the query distribution as the target distribution, and the target distribution as the query distribution. Overwrite memory is an experimental feature to overwrite the memory of the marginal distributions with those of the queries in case the distribution of the target points are assumed to be unknown. The n_jobs parameter allows for parallel computation, where -1 uses all available cores.
Experiment Codebooks
This library is accompanied by a set of codebooks that demonstrate how to use the library and replicate the results shown in the paper "Similarity Based on Resample Exposure". The codebooks are designed to be used in Jupyter notebooks and provide step-by-step instructions for running experiments and generating synthetic data.
Below is codebooks that can be used to replicate the results shown in the paper.
| Link | Description | Fig. refs. |
|---|---|---|
| Codebook 1 | Figures and experiments exploring behaviour of resample exposure | Fig.3 |
| Codebook 2 | Experiments and results for nearest neighbours classification | Fig.4 |
| Codebook 3 | Experiments and results for the partitioning around medoids | Fig.5 |
Library Requirements
- pandas
- numpy
- joblib
Experiment Requirements
- seaborn
- matplotlib
- scikit-learn
- scipy
- gower
- json
- ucimlrepo
Metadata
Release files for rex-score 1.1
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 |
|---|---|---|---|---|
| rex_score-1.1.tar.gz | 12.9 kB | With provenance | Details for rex_score-1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rex_score-1.1-py3-none-any.whl | Python 3 | none | any | Details for rex_score-1.1-py3-none-any.whl |
Total release size: 25.5 kB
Release files / rex_score-1.1.tar.gz
| Download URL | rex_score-1.1.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edac77127feb7e901d7e8aebc2b55e1cdd4409f29117e9da2b4d76880e5dd2fc
|
|
BLAKE2b-256 checksum How to use checksums |
34a16e3647c44696d8229bd18d18ff2d20e4673060328761c534a06a523bc134
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2025.
Transparency logRelease files / rex_score-1.1-py3-none-any.whl
| Download URL | rex_score-1.1-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a10d6fdf6c626865cad25041a3ad9aa1d60029f8a2940e8c981bdf538a81644a
|
|
BLAKE2b-256 checksum How to use checksums |
460526b2781c88e7ade6d694cf0280dafe5ea4003a688285bdd3bc597d316058
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2025.
Transparency logSecurity for rex-score 1.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for rex_score-1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2025.
Transparency logA 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.