Skip to main content

ShyapleyFDA

This is a very initial implementation of Functional relevance based on the continuous Shapley value. There is still a lot of work to do.

Install

ShapleyFDA can be installed from PyPI:

pip install ShapleyFDA

How to use

import numpy as np
from shapley_fda import ShapleyFda
from matplotlib import pyplot as plt

# Generate and visualise the data
step = 0.01
sample_size = 500
intercept = 0
slope = 1
abscissa_points = np.arange(0, 1 + step, step)
total_abscissa_points = abscissa_points.shape[0]
if total_abscissa_points % 2 == 0:
    middle_point = total_abscissa_points/2
else:
    middle_point = (total_abscissa_points + 1)//2
# Generate normal observations
np.random.seed(1234)
data = np.random.normal(
    size=(sample_size, total_abscissa_points),
    loc=0,
    scale=1
)
data = np.divide(data, np.sqrt(total_abscissa_points))
brownian = np.cumsum(data, axis=1)
trend = np.reshape(
    np.add(intercept, np.multiply(slope, abscissa_points)),
    newshape=(1, -1)
)
col_vector_ones_sample_size = np.ones(shape=(sample_size, 1))
trend_matrix = np.matmul(
    col_vector_ones_sample_size,
    trend
)
brownian_trend = np.add(brownian, trend_matrix)
_ = plt.plot(abscissa_points, brownian_trend.T)

def pred_fn(X):
    result = np.abs(X[:, middle_point])
    return result
target = pred_fn(brownian_trend)

# Use ShapleyFDA library
num_intervals = 10
num_permutations = 100
shapley_fda = ShapleyFda(
    X=brownian_trend,
    abscissa_points=abscissa_points,
    target=target,
    domain_range=(0, 1),
    verbose=False,
)
shapley_value = shapley_fda.compute_shapley_value(
    num_permutations=num_permutations,
    predict_fns=pred_fn,
    num_intervals=num_intervals,
    compute_mrmr_r2=False,
    compute_mrmr_distance_correlation=False,
)

# Plot the Shapley value function
shapley_fda.plot()

Citations

Please if you use this package, do not forget to cite us:

@misc{delicado2024functionalrelevancebasedcontinuous,
    title={Functional relevance based on the continuous Shapley value}, 
    author={Pedro Delicado and Cristian Pachón-García},
    year={2024},
    eprint={2411.18575},
    archivePrefix={arXiv},
    primaryClass={stat.ML},
    url={https://arxiv.org/abs/2411.18575}, 
}

Metadata

Release files for ShapleyFDA 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ShapleyFDA 0.0.2
File Size Uploaded Provenance Actions
shapleyfda-0.0.2.tar.gz 47.7 kB Without provenance Details for shapleyfda-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ShapleyFDA 0.0.2
File Interpreter ABI Platform Actions
ShapleyFDA-0.0.2-py3-none-any.whl Python 3 none any Details for ShapleyFDA-0.0.2-py3-none-any.whl

Total release size: 82.5 kB

Release files / shapleyfda-0.0.2.tar.gz

Download URL shapleyfda-0.0.2.tar.gz
Size 47.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4838cb66fe7f8fabc095e16f205d352e2388ad9d5ce48e402c8eae74482f5fca
BLAKE2b-256 checksum
How to use checksums
fb5d1526b9697a8c94d0a510d2d284de0439e0b35108f8c3e83450673fdbbf45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.17

Release files / ShapleyFDA-0.0.2-py3-none-any.whl

Download URL ShapleyFDA-0.0.2-py3-none-any.whl
Size 34.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aacb85efbfed451959367716a2b89495a4614c8568829708bb64358727da0d31
BLAKE2b-256 checksum
How to use checksums
cba3794c0dc07608ea3a34d1ec647ff73f5dbba1d2bcc2a55661f9640a0cf233
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.17

Security for ShapleyFDA 0.0.2

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page