It is used to quickly establish membership functions for subsequent fuzzy transformations.
Project description
Thank you for using memfunc.
Here are some tutorials to help you get started quickly.
linear membership function
Membership functions can be divided into linear and nonlinear. There are two types of linear equations: Triangular and Trapezoidal. To use them you can refer to the following code. First create the combination to be converted, and set the upper and lower limits of the conversion, then create a group of membership function combinations "head" and "end" parameters are the ratio of the leftmost and rightmost ends of the membership function.
from memfunc.memfunc.linear import Container, Triangular, Trapezoidal
x = [1, 3, 6, 5, 2, 4, 3.5, 4.5, 1.2]
minx = [0 for _ in range(len(x))]
maxx = [6 for _ in range(len(x))]
mf = Container(head=1 / 6, end=1 / 6, maxlst=maxx, minlst=minx)
mf.add(Trapezoidal(p=1 / 6, beta=1 / 6))
mf.add(Triangular(p=1 / 6, end=True))
print(mf.transform(x))
nonlinear membershipfunction
Nonlinear equations are more commonly used, and pymf supports the use of Gaussian, Generalizedbell, Sigmoid, Left, and Right equations.
from memfunc.memfunc.nonlinear import Fuzzy, Sigmoid_mf, Gaussian_mf
x = [1, 3, 6, 5, 2, 3]
min0 = [0 for _ in range(len(x) - 1)]
max0 = [10 for _ in range(len(x) - 1)]
mf = Fuzzy(minlst=min0, maxlst=max0)
mf.add(Sigmoid_mf(a=2, p=2 / 3))
mf.add(Gaussian_mf(p=1 / 2, sigma=1))
mf.add(Sigmoid_mf(a=-2, p=1 / 3))
x = mf.transform(x)
print(x)
mf.plot()
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
File details
Details for the file memfunc-0.0.1.tar.gz
.
File metadata
- Download URL: memfunc-0.0.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9caf04117235f8bf5e6046c17434cccd3b5f49e0889aac165e85054d9d91a94 |
|
MD5 | 034b20c5e9c59786108e6ff0fefb4e71 |
|
BLAKE2b-256 | 2a9f2fc38d82a6b5fb37e842f642af92531168168e1009e9f704d3212c36aedc |
File details
Details for the file memfunc-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: memfunc-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9fdaf085151e377d09c85654c93fe1c9dcbbd02292df541ee070b0a8d111c6e |
|
MD5 | 7ecb6606ecc6e16a8e92dafe1abc31bd |
|
BLAKE2b-256 | 9615f8b3811fdbbe5df3f3844bb77bf549c14ca39aaeb45e56669a066ea85a01 |