Skip to main content

pyFUME

pyFUME is a Python package for automatic Fuzzy Models Estimation from data [1]. pyFUME contains functions to estimate the antecedent sets and the consequent parameters of a Takagi-Sugeno fuzzy model directly from data. This information is then used to create an executable fuzzy model using the Simpful library. pyFUME also provides facilities for the evaluation of performance. For more information about pyFUME's functionalities, please check the online documentation.

Usage

For the following example, we use the Concrete Compressive Strength data set [2] as can be found in the UCI repository. The code in Example 1 is simple and easy to use, making it ideal to use for practitioners who wish to use the default settings or only wish to use few non-default settings using additional input arguments (Example 2). Users that wish to deviate from the default settings can use the code as shown in Example 3.

Example 1

from pyfume import pyFUME

# Set the path to the data and choose the number of clusters
path='./Concrete_data.csv'
nc=3

# Generate the Takagi-Sugeno FIS
FIS = pyFUME(datapath=path, nr_clus=nc)

# Calculate and print the accuracy of the generated model
MAE=FIS.calculate_error(method="MAE")
print ("The estimated error of the developed model is:", MAE)

## Use the FIS to predict the compressive strength of a new concrete sample
# Extract the model from the FIS object
model=FIS.get_model()

# Set the values for each variable
model.set_variable('Cement', 300.0)
model.set_variable('BlastFurnaceSlag', 50.0)
model.set_variable('FlyAsh', 0.0)
model.set_variable('Water', 175.0)
model.set_variable('Superplasticizer',0.7)
model.set_variable('CoarseAggregate', 900.0)
model.set_variable('FineAggregate', 600.0)
model.set_variable('Age', 45.0)

# Perform inference and print predicted value
print(model.Sugeno_inference(['OUTPUT']))

Example 2

from pyfume import pyFUME

# Set the path to the data and choose the number of clusters
path='./Concrete_data.csv'
nc=3

# Generate the Takagi-Sugeno FIS
FIS = pyFUME(datapath=path, nr_clus=nc, normalization='minmax', feature_selection=True)

# Calculate and print the accuracy of the generated model
MAE=FIS.calculate_error(method="MAE")
print ("The estimated error of the developed model is:", MAE)

## Use the FIS to predict the compressive strength of a new concrete sample
# Extract the model from the FIS object
model=FIS.get_model()

# Set the values for each variable
model.set_variable('Cement', 300.0)
model.set_variable('BlastFurnaceSlag', 50.0)
model.set_variable('FlyAsh', 0.0)
model.set_variable('Water', 175.0)
model.set_variable('Superplasticizer',0.7)
model.set_variable('CoarseAggregate', 900.0)
model.set_variable('FineAggregate', 600.0)
model.set_variable('Age', 45.0)

# Perform inference and print predicted value
print(model.Sugeno_inference(['OUTPUT']))

Example 3

from pyfume import *

# Set the path to the data and choose the number of clusters
path='./Concrete_data.csv'
nr_clus=3

# Load and normalize the data using min-max normalization
dl=DataLoader(path,normalize='minmax')
variable_names=dl.variable_names 
dataX=dl.dataX
dataY=dl.dataY

# Split the data using the hold-out method in a training (default: 75%) 
# and test set (default: 25%).
ds = DataSplitter()
x_train, y_train, x_test, y_test = ds.holdout(dataX=dl.dataX, dataY=dl.dataY)

# Select features relevant to the problem
fs=FeatureSelector(dataX=x_train, dataY=y_train, nr_clus=nr_clus, variable_names=variable_names)
selected_feature_indices, variable_names=fs.wrapper()

# Adapt the training and test input data after feature selection
x_train = x_train[:, selected_feature_indices]
x_test = x_test[:, selected_feature_indices]

# Cluster the training data (in input-output space) using FCM with default settings
cl = Clusterer(x_train=x_train, y_train=y_train, nr_clus=nr_clus)
cluster_centers, partition_matrix, _ = cl.cluster(method="fcm")

# Estimate the membership funtions of the system (default: mf_shape = gaussian)
ae = AntecedentEstimator(x_train=x_train, partition_matrix=partition_matrix)
antecedent_parameters = ae.determineMF()

# Calculate the firing strength of each rule for each data instance        
fsc=FireStrengthCalculator(antecedent_parameters=antecedent_parameters, nr_clus=nr_clus, variable_names=variable_names)
firing_strengths = fsc.calculate_fire_strength(data=x_train)

# Estimate the parameters of the consequent functions
ce = ConsequentEstimator(x_train=x_train, y_train=y_train, firing_strengths=firing_strengths)
consequent_parameters = ce.suglms()

# Build a first-order Takagi-Sugeno model using Simpful. Specify the optional 
# 'extreme_values' argument to specify the universe of discourse of the input
# variables if you which to use Simpful's membership function plot functionalities.
simpbuilder = SugenoFISBuilder(antecedent_sets=antecedent_parameters, consequent_parameters=consequent_parameters, variable_names=variable_names)
model = simpbuilder.get_model()

# Calculate the mean squared error (MSE) of the model using the test data set
test=SugenoFISTester(model=model, test_data=x_test, variable_names=variable_names, golden_standard=y_test)
MAE = test.calculate_MAE()

print('The mean absolute error of the created model is', MAE)

Installation

pip install pyfume

Further information

If you need further information, please write an e-mail to Caro Fuchs: c.e.m.fuchs(at)tue.nl.

References

[1] Fuchs, C., Spolaor, S., Nobile, M. S., & Kaymak, U. (2020) "pyFUME: a Python package for fuzzy model estimation". In 2020 IEEE International Conference on Fuzzy Systems (FUZZ-IEEE) (pp. 1-8). IEEE.

[2] I-Cheng Yeh, "Modeling of strength of high performance concrete using artificial neural networks," Cement and Concrete Research, Vol. 28, No. 12, pp. 1797-1808 (1998). http://archive.ics.uci.edu/ml/datasets/Concrete+Compressive+Strength

Download files

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

Source Distribution

pyFUME-0.1.22.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

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

pyFUME-0.1.22-py3-none-any.whl (54.0 kB view details)

Uploaded Python 3

File details

Details for the file pyFUME-0.1.22.tar.gz.

File metadata

  • Download URL: pyFUME-0.1.22.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

File hashes

Hashes for pyFUME-0.1.22.tar.gz
Algorithm Hash digest
SHA256 c1c8b1ef951e3b165fdc6a632b52d1bce55825bf3a5688306da64c207bc53bc3
MD5 54ed279b22b2a8f78dde1b6dfde0b671
BLAKE2b-256 50eee11c1edc6be4e4a969a1ce5278a54d04df2de64c7581f99364c328f6219c

See more details on using hashes here.

File details

Details for the file pyFUME-0.1.22-py3-none-any.whl.

File metadata

  • Download URL: pyFUME-0.1.22-py3-none-any.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

File hashes

Hashes for pyFUME-0.1.22-py3-none-any.whl
Algorithm Hash digest
SHA256 b078de95873048c4aeeaa426a4c2986eb4a710f0082a5928e1d09fce7d3edf4d
MD5 47af0a8abb80a4adf6b843927b5f1743
BLAKE2b-256 10c7b5d21914839bc715c68b9640f4b68b55d96806fc103c2ecff6272104a9f3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.4

2 files

0.3.1

2 files

0.3.0

2 files

0.2.25

2 files

0.2.24

2 files

0.2.23

2 files

0.2.22

2 files

0.2.20

2 files

0.2.19

2 files

0.2.18

2 files

0.2.17

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.29

2 files

0.1.28

2 files

0.1.27

2 files

0.1.26

2 files

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

This release

0.1.22 This release

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

2 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