A Python library for fuzzy membership calculations
Project description
xkfuzzy
A simple Python library for fuzzy membership calculations.
Installation
pip install -e .
Usage
The library provides a single function calculate_membership that can compute fuzzy membership values using different membership functions.
Basic Usage
import xkfuzzy
# Triangular membership function
membership_value = xkfuzzy.calculate_membership(
value=5,
membership_type="triangular",
a=0, b=5, c=10
)
print(membership_value) # Output: 1.0
Supported Membership Functions
1. Triangular Membership
# Parameters: a, b, c (where a < b < c)
membership = xkfuzzy.calculate_membership(
value=3,
membership_type="triangular",
a=0, b=5, c=10
)
2. Trapezoidal Membership
# Parameters: a, b, c, d (where a < b < c < d)
membership = xkfuzzy.calculate_membership(
value=3,
membership_type="trapezoidal",
a=0, b=2, c=8, d=10
)
3. Gaussian Membership
# Parameters: center, sigma
membership = xkfuzzy.calculate_membership(
value=2,
membership_type="gaussian",
center=0, sigma=1
)
4. Bell-shaped Membership
# Parameters: a (width), b (slope), c (center)
membership = xkfuzzy.calculate_membership(
value=1,
membership_type="bell",
a=1, b=2, c=0
)
Working with Arrays
The function also supports numpy arrays:
import numpy as np
import xkfuzzy
values = np.array([0, 2, 5, 8, 10])
memberships = xkfuzzy.calculate_membership(
value=values,
membership_type="triangular",
a=0, b=5, c=10
)
print(memberships) # Output: [0.0, 0.4, 1.0, 0.4, 0.0]
Function Signature
calculate_membership(value, membership_type="triangular", **params)
Parameters:
value: Input value(s) for which to calculate membership (float or array-like)membership_type: Type of membership function ("triangular", "trapezoidal", "gaussian", "bell")**params: Parameters specific to the membership function type
Returns:
- Membership value(s) between 0 and 1
Requirements
- Python 3.7+
- NumPy 1.19.0+
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xkfuzzy-0.1.0.tar.gz.
File metadata
- Download URL: xkfuzzy-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e673fe6233d60e7044782be728a91270011bb8856c70bf2dda81387766640900
|
|
| MD5 |
f719e3c08f5f9aed966e2ce955ffcc89
|
|
| BLAKE2b-256 |
e3dfd71e3d5ebb511c4c4b7b49585f43915eefb405a2781bbd10f7137316a36c
|
File details
Details for the file xkfuzzy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xkfuzzy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
380bf708030cd580835c22b7c8de05443ece4f9798291abf4d3fe9e4373baf5b
|
|
| MD5 |
27cb1e64edec63ade7bad81a5a9ca84e
|
|
| BLAKE2b-256 |
ab2880a7eaa4b1de0b13190c808322e1e5b39835db083f7956f20fa84cbf1fb4
|