
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
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:
.fit()
, .predict()
, .score()
and compatible with GridSearchCV
, Pipeline
, etc.SGD
, Adam
, RMSprop
, Adagrad
, AdamW
, ...GA
, PSO
, ACO
, WOA
, BA
, FFA
, CSA
, GWO
, ABC
, DE
, ...Triangular
, Gaussian
, Bell
, ...Model Class | Training Method | Type |
---|---|---|
AnfisRegressor , AnfisClassifier | Classic Hybrid | Regression / Classification |
GdAnfisRegressor , GdAnfisClassifier | Gradient-based | Regression / Classification |
BioAnfisRegressor , BioAnfisClassifier | Metaheuristic-based | Regression / Classification |
Please include these citations if you plan to use this library:
@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}
}
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.
Install the latest version using pip:
pip install xanfis
After that, check the version to ensure successful installation:
$ python
>>> import xanfis
>>> xanfis.__version__
Let's say I want to use Adam optimization-based ANFIS for Iris classification dataset. Here how to do it.
from xanfis import Data, GdAnfisClassifier
from sklearn.datasets import load_iris
## Load data object
X, y = load_iris(return_X_y=True)
data = Data(X, y)
## Split train and test
data.split_train_test(test_size=0.2, random_state=2, inplace=True, shuffle=True)
print(data.X_train.shape, data.X_test.shape)
## Scaling dataset
data.X_train, scaler_X = data.scale(data.X_train, scaling_methods=("standard", "minmax"))
data.X_test = scaler_X.transform(data.X_test)
data.y_train, scaler_y = data.encode_label(data.y_train)
data.y_test = scaler_y.transform(data.y_test)
print(type(data.X_train), type(data.y_train))
## Create model
model = GdAnfisClassifier(num_rules=20, mf_class="Gaussian",
act_output=None, vanishing_strategy="blend", reg_lambda=None,
epochs=50, batch_size=16, optim="Adam", optim_params={"lr": 0.01},
early_stopping=True, n_patience=10, epsilon=0.001, valid_rate=0.1,
seed=42, verbose=True)
## Train the model
model.fit(X=data.X_train, y=data.y_train)
## Test the model
y_pred = model.predict(data.X_test)
print(y_pred)
print(model.predict_proba(data.X_test))
## Calculate some metrics
print(model.evaluate(y_true=data.y_test, y_pred=y_pred, list_metrics=["F2S", "CKS", "FBS", "PS", "RS", "NPV", "F1S"]))
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.
Explore other projects by the author:
Developed by: Thieu @ 2025
FAQs
X-ANFIS: An Extensible and Cross-Learning ANFIS Framework for Machine Learning Tasks
We found that xanfis demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.