Skip to main content

A Python library for fuzzy-rough set utility functions.

Project description

FRsutils Logo

Installation

$pip install frsutils

  • Requirements
    • Python
    • Numpy

Fuzzy-Rough set utilities (Under development)

A basic Python library needed for fuzzy rough set calculations e.g.:

  • lower approximation
  • upper approximation
  • positive region
  • boundry region

Algorithgms and containings

  • Similarities
    • Linear
    • Gaussian
  • Implicators
    • Gaines
    • Goedel
    • Kleene–Dienes
    • Reichenbach
    • Lukasiewicz
  • T-norms
    • min tnorm
    • product tnorm
    • Lukasiewicz tnorm
  • OWA weights (Ordered Weighted Average)
    • Linear
  • ITFRS (Implicator/T-norm Fuzzy-Rough Sets)
  • OWAFRS (Ordered Weighted Average Fuzzy-Rough Sets)

Notes

  • All functions expect to get normalized scalar of normalized numpy arrays.
  • Make sure the input dataset is normalized. This library expects all inputs to all functions are in range [0,1]
  • This library will use all features of data instances to calculate the fuzzzy-rough measures.

Some technical information to remember

In ITFRS

lower approximation for each instance:

lower aaproximation

upper approximation for each instance:

upper aproximation

Since for the calculations of lower approximation, we calculate Inf which is basically a minimum, to exclude the same instance from calculations we don’t need anything because the main diagonal is set to 1.0 which is ignored by min operator. To be sure all is correct, inside code, we set main diagonal to 1.0

Since for the calculations of upper approximation, we calculate sup which is basically a maximum, to exclude the same instance from calculations we need to set the main diagonal to 0.0 which is ignored by max operator. Otherwise all upper approxamations will be 1.0.

In ITFRS, POS(x) = lower_approximation(x) where x is a data instance, and datasets having crisp classes.

In OWAFRS

lower approximation for each instance:

lower aaproximation

upper approximation for each instance:

upper aproximation

Since for the calculations of lower approximation, we calculate soft Inf which is basically a product, to exclude the same instance from calculations we set the main diagonal to 0.0

Since for the calculations of upper approximation, we calculate soft sup which is basically a product, to exclude the same instance from calculations we need to set the main diagonal to 0.0 which is ignored by max operator. Otherwise all upper approxamations will be 1.0.

In OWAFRS, POS(x) = ????????????????????????

OWA weights

OWA weights are used for softening strict operators: inf and sup. They are a set of weights ordered in ascending or descending based on the use. they are shown by W={w1, w2,...wn} and they are multiplied by vector V{v1,v2,...vn}. Assume V is always ordered in dissending order, namely v1 is the max and vn is the min.

  • For inf calculations, which is basically a minimum, higher values of W will be multiplied by lower values of V. This means W is ordered as ascending order; Namely w1 is the smallest value and wn is the biggest value in vector W. Then, OWA(W,V) = w1.v1 + w2.v2 + ... wn.vn
  • For sup calculations, which is basically a maximum, higher values of W will be multiplied by higher values of V. This means W is ordered as decending order; Namely w1 is the biggest value and wn is the smallest value in vector W. Then, OWA(W,V) = w1.v1 + w2.v2 + ... wn.vn

tnorms

  • works on 1D vectors (for aggregating the values to a scalar in similarity calculations)
  • works on nxnx2 maps for fast calculations
  • min tnorm and product tnorm will act the same if one of the input parameters takes the binary values; So, no matter which one you use, they provide the same reults
min_tnorm
product_tnorm

Implicators

  • Since in this library, A(y) in implicators--if instance x has the same class of instance y, is used, therefore different implicators boil down to the same thing:
    • Goedel and Gaines produce the same results
    • KD, Reichenbach and Luk also produce the same results
  • implicators work on scalar but can be vectorized with np.vectorize()
  • implicators do not generate the same values for these (0,0) , (1,0) , (0,1) , (1,1). Their behavior is different. Do not draw a general conclusion on them.
Luk
Goedel
KD
Reichenbach
Gaines

where x, y are two data instances; A(y) means if the instance y has the same class as X and returns 0.0 or 1.0.

Docs

  • We use Doxygen-style (Javadoc-like) Python Docstrings and documents are generated by Doxygen
  • To see online documentations, please visit online documentations

How to run tests

These are two ways:

  • use pytest and it finds and runs all tests
  • If you want to run tests in debug mode, find and run the file experimental_tests.py (Make sure all functions in test files are called in this file. Maybe some are forgotten)

Technical decisions justification

TODO:

  • Add tests for tnorms with non-binary masks
  • Implemene and debug VQRS (Vaguely Quantified Rough Sets)

License

This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.

How to Cite us in your research papers

If you use this library in your research, please cite it as follows:

APA :

Mehran Amiri. (2025). FRsutils (Version 0.0.1) [Computer software]. https://github.com/mehi64/FRsutils

BibTeX (for LaTeX users):

@software{Mehran_Amiri_FRsutils_2025,
  author = {Amiri, Mehran},
  title = {FRsutils},
  url = {https://github.com/mehi64/FRsutils},
  version = {0.0.1},
  year = {2025}
}```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frsutils-0.0.3.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

frsutils-0.0.3-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file frsutils-0.0.3.tar.gz.

File metadata

  • Download URL: frsutils-0.0.3.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for frsutils-0.0.3.tar.gz
Algorithm Hash digest
SHA256 28474a75bcf19f9a986629a7e5f4c3877c05fea99c80efeb5596d272c0d107c5
MD5 b0bef151d1208d699d08a10335cc9ec1
BLAKE2b-256 7f3df82a005086f8db7cebc51aeaa1f5dd999f2b0475f464ecd7f49a1576e304

See more details on using hashes here.

File details

Details for the file frsutils-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: frsutils-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for frsutils-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8fbdda073fe41283139ff79afd64caacdfe826be44c5128383aae5d0b8f799db
MD5 006e91667fe617e9831d8e558ed9c114
BLAKE2b-256 46a3f64ae55677243d8e48e546c26cd3afe7897bed1ee810e88a08a79b4cd4c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page