xanfis

X-ANFIS: An Extensible and Cross-Learning ANFIS Framework for Machine Learning Tasks

https://github.com/thieu1995/x-anfis

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.1%) to scientific vocabulary

Keywords

adaptive-neuro-fuzzy-inference-system anfis-network artificial-neural-fuzzy-inspired-system classification fuzzy-neural-network fuzzy-system global-search machine-learning mealpy metaheuristic-algorithms metaheuristic-based-anfis nature-inspired nature-inspired-computing-based-anfis neural-network regression
Last synced: 4 months ago · JSON representation ·

Repository

X-ANFIS: An Extensible and Cross-Learning ANFIS Framework for Machine Learning Tasks

Basic Info
Statistics
  • Stars: 12
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 5
Topics
adaptive-neuro-fuzzy-inference-system anfis-network artificial-neural-fuzzy-inspired-system classification fuzzy-neural-network fuzzy-system global-search machine-learning mealpy metaheuristic-algorithms metaheuristic-based-anfis nature-inspired nature-inspired-computing-based-anfis neural-network regression
Created over 2 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License Code of conduct Citation

README.md

X-ANFIS: Modular ANFIS Library with Classic, Gradient, and Bio-inspired Training Strategies

GitHub release Wheel PyPI version PyPI - Python Version PyPI - Downloads Downloads Tests & Publishes to PyPI Documentation Status Chat DOI License: GPL v3


X-ANFIS is a Python library offering a powerful and extensible implementation of Adaptive Neuro-Fuzzy Inference System (ANFIS) using PyTorch and Scikit-Learn. The library is written with object-oriented principles and modular architecture, enabling easy customization, integration, and experimentation.It supports:

  • 🔧 Classic ANFIS (Hybrid: Gradient Descent + Least Squares)
  • 🌊 Gradient-based ANFIS (Fully differentiable training)
  • 🧠 Bio-inspired ANFIS (Metaheuristics + Least Squares)

✨ Key Features

  • Modular, object-oriented design for ease of extension.
  • Scikit-Learn API: .fit(), .predict(), .score() and compatible with GridSearchCV, Pipeline, etc.
  • Wide range of Gradient-based training optimizers: SGD, Adam, RMSprop, Adagrad, AdamW, ...
  • Wide range of Bio-inspired optimizers: GA, PSO, ACO, WOA, BA, FFA, CSA, GWO, ABC, DE, ...
  • Rich membership functions: Triangular, Gaussian, Bell, ...
  • Over 67 built-in metrics and losses.

🧠 Model Zoo

| Model Class | Training Method | Type | |-------------------------------------------|---------------------|-----------------------------| | AnfisRegressor, AnfisClassifier | Classic Hybrid | Regression / Classification | | GdAnfisRegressor, GdAnfisClassifier | Gradient-based | Regression / Classification | | BioAnfisRegressor, BioAnfisClassifier | Metaheuristic-based | Regression / Classification |

📌 Citation

Please include these citations if you plan to use this library:

```bibtex @software{thieu20250414, author = {Nguyen Van Thieu}, title = {X-ANFIS: An Extensible and Cross-Learning ANFIS Framework for Machine Learning Tasks}, month = June, year = 2025, doi = {10.6084/m9.figshare.28802531}, url = {https://github.com/thieu1995/X-ANFIS} }

@article{van2023mealpy, title = {MEALPY: An open-source library for latest meta-heuristic algorithms in Python}, author = {Van Thieu, Nguyen and Mirjalili, Seyedali}, journal = {Journal of Systems Architecture}, year = {2023}, publisher = {Elsevier}, doi = {10.1016/j.sysarc.2023.102871} } ```

⚙️ General tutorial

Below tutorial is how you can install and use this library. For more complex examples and documentation please check the examples folder and documentation website.

📦 Installation

Install the latest version using pip:

bash pip install xanfis

After that, check the version to ensure successful installation:

```bash $ python

import xanfis xanfis.version ```

🧪 Quick Example

Let's say I want to use Adam optimization-based ANFIS for Iris classification dataset. Here how to do it.

```python from xanfis import Data, GdAnfisClassifier from sklearn.datasets import load_iris

Load data object

X, y = loadiris(returnX_y=True) data = Data(X, y)

Split train and test

data.splittraintest(testsize=0.2, randomstate=2, inplace=True, shuffle=True) print(data.Xtrain.shape, data.Xtest.shape)

Scaling dataset

data.Xtrain, scalerX = data.scale(data.Xtrain, scalingmethods=("standard", "minmax")) data.Xtest = scalerX.transform(data.X_test)

data.ytrain, scalery = data.encodelabel(data.ytrain) data.ytest = scalery.transform(data.y_test)

print(type(data.Xtrain), type(data.ytrain))

Create model

model = GdAnfisClassifier(numrules=20, mfclass="Gaussian", actoutput=None, vanishingstrategy="blend", reglambda=None, epochs=50, batchsize=16, optim="Adam", optimparams={"lr": 0.01}, earlystopping=True, npatience=10, epsilon=0.001, validrate=0.1, seed=42, verbose=True)

Train the model

model.fit(X=data.Xtrain, y=data.ytrain)

Test the model

ypred = model.predict(data.Xtest) print(ypred) print(model.predictproba(data.X_test))

Calculate some metrics

print(model.evaluate(ytrue=data.ytest, ypred=ypred, list_metrics=["F2S", "CKS", "FBS", "PS", "RS", "NPV", "F1S"])) ```

💬 Contributing

We welcome contributions to X-ANFIS! If you have suggestions, improvements, or bug fixes, feel free to fork the repository, create a pull request, or open an issue.

X-ANFIS allows for customization at various levels, including:

  • Membership Functions: You can define custom membership functions to fit your problem requirements.

  • Learning Strategies: Easily switch between gradient-based or bio-inspired algorithms for training.

  • Model Components: Customize the architecture of the ANFIS model, including the number of input and output nodes, output activation function, number of rules, and rule strengths, L2 regularization, training methods.

📞 Community & Support

🧩 Related Projects

Explore other projects by the author:


Developed by: Thieu @ 2025

Owner

  • Name: Nguyen Van Thieu
  • Login: thieu1995
  • Kind: user
  • Location: Earth
  • Company: AIIR Group

Knowledge is power, sharing it is the premise of progress in life. It seems like a burden to someone, but it is the only way to achieve immortality.

Citation (CITATION.cff)

cff-version: 1.1.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: "Van Thieu"
    given-names: "Nguyen"
    orcid: "https://orcid.org/0000-0001-9994-8747"
title: "X-ANFIS: An Extensible and Cross-Learning ANFIS Framework for Machine Learning Tasks"
doi: "10.5281/zenodo.1234567"
version: v1.1.0
doi: 10.6084/m9.figshare.28802531
date-released: 2025-06-07
url: "https://github.com/thieu1995/X-ANFIS"

GitHub Events

Total
  • Release event: 4
  • Watch event: 6
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 22
  • Create event: 5
Last Year
  • Release event: 4
  • Watch event: 6
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 22
  • Create event: 5

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 309 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
pypi.org: xanfis

X-ANFIS: An Extensible and Cross-Learning ANFIS Framework for Machine Learning Tasks

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 309 Last month
Rankings
Dependent packages count: 9.3%
Average: 30.9%
Dependent repos count: 52.4%
Maintainers (1)
Last synced: 5 months ago