Skip to main content

Pyfmtools

Pyfmtools provides various tools for handling fuzzy measures, calculating various indices, Choquet and Sugeno integrals, as well as fitting fuzzy measures to empirical data. This package is designed for Python , but it also includes the C++ source files and a user manual. Chapter 2 of the user manual provides some background on fuzzy measures. A more detailed overview can be found in [4, 5, 12, 16] and references therein. Chapter 3 of the user manual outlines computational methods used to fit fuzzy measures to empirical data. The description of the programming library pyfmtools is given in Chapter 4. Examples of its usage are provided in Section 4.6. To cite pyfmtools package, use references [2–6,21–24].

New in version 4

Random generation of fuzzy measures of different types, including k-additive, k-interactive, supermodular and submodular, sparse representation of k- additive fuzzy measures.

We added in version 3

We added the concept of K-interactive fuzzy measures, and 4 methods of fitting K-interactive fuzzy measures from data based on linear program- ming. K-interactive fuzzy measures significantly reduce the computational complexity. We also added fitting fuzzy measures in marginal contribution representation and using maximal chains method, which fits only the values directly identifiable from the data. This method is useful for small data sets. Fitting fuzzy measures in marginal contribution representation allows simple sub and supermodularity constraints, which can now be enforced. See functions fittingKinteractive, fittingKinteractiveAuto, fittingKinter- activeMC, fittingKinteractiveMarginal, fittingKinteractiveMarginalMC. We added calculation of new non-additivity and bipartition interaction indices. See functions Bipartition, BipartitionBanzhaf, NonadditivityIndex, NonadditivityIndexMob.

We added in version 2

We added fitting K-maxitive and K-tolerant fuzzy measures, based on linear and mixed integer programming. See functions fittingktolerant and fittingK- maxitive. We added a method for fitting sub-modular fuzzy measures reported in [3]. Supermodular fuzzy measure can also be fit by using duality: construct dual data set, fit a sub-modular fuzzy measure and then compute its dual. See function FuzzyMeasureFitLP. We added an extra requirement of preservation of output ordering. See function FuzzyMeasureFitLP. Fixed many warnings in the lpsolve code.

Documentation

User Manual

Installation

To install type:

$ pip install pyfmtools

Usage of the library

How to use the library with Python only

import pyfmtools as pyfm

Follow these steps in your Python code to use the library:

  • Initialize resources
  • Use library function(s)
  • Free resources

Example how to initialize resources

n=3<br>
env = pyfm.fm_init( n)<br>

Example how to free resources

pyfm.fm_free( env)<br>

Usage of library functions

To implement a function follow these steps:

  1. Initialize input arrays.
  2. Initialize input parameters.
  3. Call wrapper function.
  4. Evaluate output parameters.

Example

import pyfmtools as pyfm

n=3
env = pyfm.fm_init( n)

k = 2
Mob =[0.0,0.3,0.5,-0.2,0.4,0.1,-0.2,0.1]
pnm = pyfm.NonmodularityIndexMobkadditive(Mob, k, env)
print( "k: ", k)
print( "Mob: ", Mob)
print( "nonmodularity indices: ", pnm)

pyfm.fm_free( env)

Parameters

Input parameters:

See input parameter list in user manual

Output parameters:

See output parameter list in user manual

Test

To unit test type:

$ test/test_wrapper.py

How to use the library utilizing NumPy and CFFI

from _pyfmtools import flib, lib

Follow these steps in your Python code to use the library:

  • Initialize resources
  • Use library function(s)
  • Free resources

Example how to initialize resources

n=3
env=ffi.new( "struct fm_env *")
fm.py_fm_init( n, env)

Example how to free resources

fm.py_fm_free( env)<br>

Usage of library functions

To implement a function follow these steps:

  1. Initialise input parameters
  2. Initialise input arrays.
  3. Covert input arrays to CFFI.
  4. Initialise output arrays.
  5. Covert output arrays to CFFI.
  6. Call C function.

Parameters

Input parameters:

See input parameter list in user manual

Output parameters:

See output parameter list in user manual

Example

import numpy as np
from  _pyfmtools import ffi,lib as fm

n=4
fm.py_fm_init(n,  env);

ti=1
v = np.zeros(env.m,float);
pv = ffi.cast("double *", v.ctypes.data);
vb = np.zeros(env.m,float);
pvb = ffi.cast("double *", vb.ctypes.data);
size = fm.py_generate_fm_2additive_concave(ti,n,pv)
print( "2-additive concave FM in Mobius and its length (n=4)")
print( v)
print( "has ", size, " nonzero parameters ")

fm.py_fm_free( env);

Test

To unit test type:

$ test/test_no_wrapper.py

Release files for pyfmtools 5.4.0

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

Source distribution (sdist)

Source distribution for pyfmtools 5.4.0
File Size Uploaded
pyfmtools-5.4.0.tar.gz 537.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyfmtools 5.4.0
File Interpreter ABI Platform
pyfmtools-5.4.0-cp314-cp314-macosx_14_0_arm64.whl CPython 3.14 CPython 3.14 macOS 14.0+ ARM64 Details

Total release size: 1.0 MB

Release files / pyfmtools-5.4.0.tar.gz

Download URL pyfmtools-5.4.0.tar.gz
Size 537.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b7e7288e51caa95d6e28c50e7e0bb43d4f1720ce762121e0d6a88573a87495ca
BLAKE2b-256 checksum
How to use checksums
cabe476900a9d7aea71824434065fd078ea5619fef093342fc658dd5680f768a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Release files / pyfmtools-5.4.0-cp314-cp314-macosx_14_0_arm64.whl

Download URL pyfmtools-5.4.0-cp314-cp314-macosx_14_0_arm64.whl
Size 507.8 kB
Tags CPython 3.14 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
56f459a03b91269fe360065d1ea9e74179fdda14a36d2bd23db93b1b2201c087
BLAKE2b-256 checksum
How to use checksums
c56129e0b0740fb9c84197b6700b9d5fd4e38335215e661b1d78cfec0c78f8de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Release history Release notifications | RSS feed

5.4.1

2 release files

This release

5.4.0 This release

2 release files

5.3.9

1 release file

5.3.8

1 release file

5.3.7

1 release file

5.3.6

1 release file

5.3.5

1 release file

5.3.4

1 release file

5.3.3

1 release file

5.3.2

1 release file

5.3.1

1 release file

5.3

1 release file

5.2.1

2 release files

5.2

2 release files

5.1

2 release files

0.81

2 release files

0.80

2 release files

0.79

2 release files

0.78

2 release files

0.77

2 release files

0.75

2 release files

0.74

2 release files

0.73

2 release files

0.72

2 release files

0.71

2 release files

0.70

2 release files

0.66

2 release files

0.65

2 release files

0.64

2 release files

0.63

2 release files

0.62

2 release files

0.61

2 release files

0.60

2 release files

0.59

2 release files

0.58

2 release files

0.57

2 release files

0.56

2 release files

0.55

2 release files

0.54

2 release files

0.53

2 release files

0.52

2 release files

0.51

2 release files

0.50

2 release files

0.42

2 release files

0.41

2 release files

0.40

2 release files

0.36

2 release files

0.35

2 release files

0.34

2 release files

0.33

2 release files

0.32

2 release files

0.31

2 release files

0.30

2 release files

0.10

2 release files

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