Skip to main content

SePYrability

Python implementation of the separability metric.

Python implementation of the Multiscale Separability metric as shown in [1]. The original paper from which the implementation was based of can be found here.

After using this package consider citing the paper from which the implementation was based of:

[1] TORRES, R. da S.; FALCAO, Alexandre X.; COSTA, L. da F. A graph-based approach for multiscale shape analysis. Pattern Recognition, v. 37, n. 6, p. 1163-1174, 2004.

Table of Contents

Multiscale Separability

The separability of a descriptor indicates it's discriminatory capabilities among individuals of the same class. It measures the effectiveness of a descriptor by showing how far data is from that descriptor.

Installation

Method 1 - PIP

Just run: pip install sepyrability

Method 2 - Manual Installation

First, clone the directory, by running:

git clone https://github.com/jrjoaorenato/SePYrability.git

The package requires the following dependencies:

  • numpy
  • matplotlib

You can install those dependencies by running the following command in the package directory: pip install -r requirements.txt

After that you can run the following command in the package directory to install the package: pip install -e .

Usage

You can import the package by using: import sepyrability.separability as sep

The default distance metrics already implemented, can be imported by: import sepyrability.distance as dis

The types of distance currently implemented are:

  1. euclidian - Euclidian distance
  2. cosine - Cosine distance

To access the distances you can use: dis.<chosen distance>.

After properly importing the package you can compute the multiscale separability with the following attributes:

sep.calculate_separability(data, labels, distfun = dis.euclidian, dx = 0.02, start= 0.01, show_graph = True):
Arguments:
    n is the number of instances
    and f is the dimensionality of the features
    data {numpy Matrix [n x f]} -- The data on which separability is going to be calculated
    labels {np.array[n]} -- label information for each piece of data
    distfun {function} -- function used to calculate distance: euclidian
    dx {float} -- step size for distance calculation
    start {float} -- starting point for the steps
    show_graph {bool} -- Boolean to show or not the multiscale separability graph

Returns:
    multiscale_separability {dictionary} -- dictionary containing:
        - 'multiscale_separability' [array of floats] -- multiscale_separability for a specific radius
        - 'distance' [array of floats] -- corresponding radius distance for multiscale_separability
    auc -- area under the curve of the separability graph
    --plots graph if 'show_graph' is True

You can easily obtain the multiscale seprability data using sep.calculate_separability(data, labels). If you want, you can also specify a different distance function from euclidian, by passing the function as an argument of distfun, including your own, as shown in the next session.

Custom Distance Function

You have the option to implement your own distance function and pass it as an argument of distfun. This can be done by creating a custom function that receives a reference point 'ref' and a data point 'X' as arguments, and returns the distance between these two points.

NOTE: The distance should be normalized between 0 and 1.

An example can be seen below:

def custom_euclidian(ref, X):
    #returns normalized euclidian distance from the reference point
    dist = X - ref
    dist = np.sqrt(np.sum(np.power(dist, 2), axis = 1))
    dist = dist/np.max(dist)
    return dist

#this can be called below by using:
ms, auc = sep.calculate_separability(Xt, Yt, distfun=dis.custom_euclidian)

Example

import sepyrability.separability as sep
import scipy.io as sio
import numpy as np

D = loadmat(<some .mat dataset location>)
X = D['X']
Y = D['Y']
ms, auc = sep.calculate_separability(Xt, Yt)

Release files for SePyrability 0.0.1

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

Source distribution (sdist)

Source distribution for SePyrability 0.0.1
File Size Uploaded
SePyrability-0.0.1.tar.gz 5.0 kB Details

Release files / SePyrability-0.0.1.tar.gz

Download URL SePyrability-0.0.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6e244b54baa2626eab94033c26c87cfb76ae3b41359f81c2fc054a9011c845ce
BLAKE2b-256 checksum
How to use checksums
97a42da706a18f36634ea183b37bf8f5ba6b170614ba27755d24a7f45eecd615
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

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