Gradient-based Fuzzy System Optimisation via Automatic Differentiation -- FuzzyR as a Use Case

Chao Chen, Christian Wagner, Jonathan M. GaribaldiarXiv 2024

TL;DR

This paper introduces the integration of automatic differentiation (autograd) into the FuzzyR toolbox by leveraging Torch for R. This allows fuzzy logic systems to be optimized using efficient gradient descent algorithms, eliminating the need for tedious manual derivative calculations while preserving the inherent interpretability of fuzzy models.

What Problem Does This Paper Address?

Fuzzy logic systems are highly valued in Explainable AI (XAI) because their rule-based structures and membership functions are easily understood by humans. However, optimizing these systems to fit data accurately has traditionally been a major bottleneck.

While deep learning has thrived due to efficient gradient-based optimization powered by automatic differentiation, fuzzy systems have lagged behind. Implementing gradient descent for fuzzy models historically required researchers to manually derive complex partial derivatives—a daunting task, especially for advanced variations like Type-2 fuzzy systems. As a result, designers were either restricted to a few mathematically convenient membership functions or forced to rely on slower, derivative-free metaheuristics like Genetic Algorithms or Particle Swarm Optimization.

Methods

The authors bridge this gap by modifying FuzzyR (an open-source R package for fuzzy inference systems) to support autograd via the Torch for R library.

To achieve autograd compatibility, the underlying data flow and operations within FuzzyR had to be converted to use torch tensors. The authors systematically replaced standard R functions that break Torch's computational graph tracking with native torch alternatives. For example:

  • Standard R primitives like pmin and pmax were replaced with torch_minimum.
  • The standard R apply function, which is unsupported by Torch, was bypassed using a combination of torch_unbind, lapply, and torch_stack.
  • Using these new primitives, they successfully implemented an autograd-compatible trapezoidal membership function (trapmf.torch) and updated core evaluation functions like evalmf and evalfis.

Datasets

The classic Iris dataset (150 instances, 4 attributes, 3 classes of iris flowers) was utilized as a benchmark. For the purpose of this demonstration, the entire dataset was used for both training and testing to showcase the optimization mechanics.

Key Insights and Ideas

  • The Best of Both Worlds: By introducing autograd to fuzzy systems, the authors demonstrate that you don't have to choose between the high performance of gradient-based machine learning and the clear explainability of fuzzy logic.
  • Liberating the Designer: Automating derivative calculations frees system designers from complex mathematics. They can now focus on creative architectural choices, such as exploring novel membership functions or building complex hierarchical fuzzy systems.
  • Data-Centric Alignment: Optimization automatically shifts uniformly distributed, "naive" initial membership functions into shapes that precisely reflect the actual data distribution, significantly boosting accuracy while remaining human-readable.

Key Results

The authors tested their autograd-enabled framework by optimizing a Mamdani-type fuzzy inference system on the Iris dataset over 100 training epochs.

  • Error Reduction: The Root Mean Square Error (RMSE) saw a sharp decline from 0.2872 to 0.1421.
  • Accuracy Boost: The number of misclassified flower instances plummeted from 22 down to just 4.

This optimization process visually tunes the membership functions from their initial uniform spacing into a data-aligned configuration:

Fig. 1. Initial membership functions of the inputs
Final membership functions after optimization

The steady convergence of the parameters ($\theta_1$) and the error reduction throughout the training process are captured in the learning curves below:

Fig. 3. The learning curves of Parameters theta1 and RMSE

Limitations and Future Work

As a preliminary proof-of-concept, this study features a few notable limitations:

  • Scope of Implementation: The demonstration was restricted to a relatively simple Mamdani-type model on a small dataset. Substantial engineering is still required to make the entire FuzzyR toolkit fully autograd-compatible, particularly for non-singleton fuzzification and advanced Type-2 fuzzy models.
  • Parameter Constraints: During gradient descent, membership function parameters can shift into mathematically invalid states (e.g., the left bound of a trapezoid crossing over the right bound). While the authors bypassed this using intermediate mapping parameters ($\psi$), they note that a robust, generalized framework for handling parameter constraints during autograd training needs further investigation.

Summary updated

Abstract

Since their introduction, fuzzy sets and systems have become an important area of research known for its versatility in modelling, knowledge representation and reasoning, and increasingly its potential within the context explainable AI. While the applications of fuzzy systems are diverse, there has been comparatively little advancement in their design from a machine learning perspective. In other words, while representations such as neural networks have benefited from a boom in learning capability driven by an increase in computational performance in combination with advances in their training mechanisms and available tool, in particular gradient descent, the impact on fuzzy system design has been limited. In this paper, we discuss gradient-descent-based optimisation of fuzzy systems, focussing in particular on automatic differentiation -- crucial to neural network learning -- with a view to free fuzzy system designers from intricate derivative computations, allowing for more focus on the functional and explainability aspects of their design. As a starting point, we present a use case in FuzzyR which demonstrates how current fuzzy inference system implementations can be adjusted to leverage powerful features of automatic differentiation tools sets, discussing its potential for the future of fuzzy system design.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Iris · datasetFuzzyR Mamdani-type inference model with autograd-compatible membership functionsmisclassified cases22 casesClassification · split: test · fine-tuned · inputs=Petal Length and Petal Width · training_epochs=100 · train_test_setup=same 150 instances used for training and testing
Source quote
L426: During 100 training epochs, we observed a marked decrease in root mean square error (RMSE), from 0.2872 to 0.1421, along with a reduction in misclassified cases from 22 to~4.
BibTeX
@misc{chen2024gradient,
  author = {Chao Chen and Christian Wagner and Jonathan M. Garibaldi},
  title = {{Gradient-based Fuzzy System Optimisation via Automatic Differentiation -- FuzzyR as a Use Case}},
  year = {2024},
  eprint = {2403.12308},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.12308},
}
Figure