Fuzzaprox
A Python package for Fuzzy approximation using F-transforms over residuated lattices.
Installation
pip install fuzzaprox
Usage
import numpy as np
from fuzzaprox import Fuzzaprox
# 0) Instantiate fuzzaprox
fa = Fuzzaprox()
# 1) Set input data to approximate
y = np.sin(np.linspace(0, 4*np.pi, 100)) + 0.4*np.random.default_rng(42).normal(size=100)
fa.set_input_data(y) # Sets Input data
# 2) Define and set FUZZY SETs shape
fa.define_fuzzy_set(base_start=0, kernel_start=12, kernel_end=14, base_end=26)
# 3) Run the approximation calculation
res = fa.run()
# Output
inp = res.input_data # res.input_data: normalized input x/y
fw = res.forward # res.forward: forward approximation (x, upper_y, bottom_y)
inv = res.inverse # res.inverse: inverse approximation (x, upper_y, bottom_y)
# 4) Optional: convert the approximations back to the original data scale
# The results above are on the normalized [0,1] scale used internally.
fwDen = fa.denormalise(fw) # ApproxResults with both y-series in original units
invDen = fa.denormalise(inv)
fa.denormalise(inv.upper_y) # a plain array of y-values works as well
Plot Results
import matplotlib.pyplot as plt
# Plot results
fig, axs = plt.subplots(2, figsize=(10, 7))
# Forward points
axs[0].plot(inp.x, inp.normalized_y)
axs[0].plot(fw.x, fw.upper_y, marker='s', linestyle='None')
axs[0].plot(fw.x, fw.bottom_y, marker='s', linestyle='None')
axs[0].set_title("Forward Approximations")
# Inverse approximations
axs[1].plot(inp.x, inp.normalized_y)
axs[1].plot(inv.x, inv.upper_y)
axs[1].plot(inv.x, inv.bottom_y)
axs[1].set_title("Inverse Approximations")
# Add spacing between subplots to prevent title overlap
plt.tight_layout(rect=[0, 0, 1, 0.98]) # Leave space for suptitle
plt.show()
History
Version 0.0.1 (September 2023) was written as part of a bachelor's thesis.
The original code is kept on the archive/v0.0.1 branch (tag v0.0.1).
From 0.0.2 onwards the package was restructured to follow Python conventions.
Acknowledgements
This package grew out of a bachelor's thesis supervised by RNDr. Martina Daňková, Ph.D., at the Department of Informatics and Computers, Faculty of Science, University of Ostrava, Czech Republic.
License
See LICENSE file for license information.
Metadata
Release files for fuzzaprox 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fuzzaprox-0.0.3.tar.gz | 15.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fuzzaprox-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.3 kB
Release files / fuzzaprox-0.0.3.tar.gz
| Download URL | fuzzaprox-0.0.3.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecfdbac56492f1580bda791c6352715e9e4e7f18d24d1d44a682d1bb4accdc02
|
|
BLAKE2b-256 checksum How to use checksums |
8023638bdbce8201620c8982c7f2b26d1fe31165c7fa09e0f27c82d179187b67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Release files / fuzzaprox-0.0.3-py3-none-any.whl
| Download URL | fuzzaprox-0.0.3-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c9b39062f49964de32b944e0621f6d24a0afb8e3ee1a136146d7a747918c189
|
|
BLAKE2b-256 checksum How to use checksums |
2c787e0aa1eaf1bca0d7f5c65eda11e62aa74491d71bf3e74a9c1f27adf92ebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|