Metadata-Version: 2.2
Name: fuzzycocopython
Version: 0.1.1
Summary: Python API for FuzzyCoco using C++ bindings
Keywords: fuzzycoco,fuzzy-logic,sklearn,bindings
Author-Email: Arthur Babey <arthur.babey@heig-vd.ch>
License: AGPL-3.0-or-later
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: C++
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Project-URL: Homepage, https://github.com/CI4CB-lab/fuzzycocopython
Project-URL: Documentation, https://CI4CB-lab.github.io/fuzzycocopython/
Project-URL: Issues, https://github.com/CI4CB-lab/fuzzycocopython/issues
Requires-Python: >=3.10
Requires-Dist: numpy
Requires-Dist: scikit-learn>=1.1.3
Requires-Dist: pandas>2.0
Requires-Dist: lfa-toolbox-v2
Requires-Dist: joblib
Provides-Extra: dev
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.3; extra == "docs"
Requires-Dist: myst-parser>=2.0; extra == "docs"
Description-Content-Type: text/markdown

# FuzzyCocoPython

[![Tests](https://github.com/CI4CB-lab/fuzzycocopython/actions/workflows/tests.yml/badge.svg)](https://github.com/CI4CB-lab/fuzzycocopython/actions/workflows/tests.yml)
[![Build](https://github.com/CI4CB-lab/fuzzycocopython/actions/workflows/build.yml/badge.svg)](https://github.com/CI4CB-lab/fuzzycocopython/actions/workflows/build.yml)
[![Coverage](https://raw.githubusercontent.com/CI4CB-lab/fuzzycocopython/main/badges/coverage.svg)](https://CI4CB-lab.github.io/fuzzycocopython/coverage/)
[![PyPI](https://img.shields.io/pypi/v/fuzzycocopython)](https://pypi.org/project/fuzzycocopython/)
[![License: AGPL-3.0-or-later](https://img.shields.io/badge/license-AGPL--3.0--or--later-success)](https://www.gnu.org/licenses/agpl-3.0.html)
[![Python Versions](https://img.shields.io/badge/python-3.10%20%E2%80%93%203.14-blue)](#installation)

[Documentation](https://CI4CB-lab.github.io/fuzzycocopython/)


Python bindings and scikit-learn style estimators for [fuzzycoco](https://github.com/CI4CB-lab/fuzzycoco),
an evolutionary fuzzy rule learning engine written in C++. This package wraps the C++ core as a Python module
and exposes `FuzzyCocoClassifier` and `FuzzyCocoRegressor` with a familiar fit/predict API.

## Features
- Train fuzzy rule-based classifiers and regressors using `fit`, `predict`, and `score`
- Inspect learned linguistic variables, rules, and activation statistics from Python
- Persist trained estimators with `save`/`load` helpers based on `joblib`


## Installation

Install from PyPI:

```bash
pip install fuzzycocopython
```

Or install from source. Make sure the following prerequisites are available:

- A C++17 compiler toolchain (GCC/Clang on Linux & macOS, MSVC on Windows)
- [CMake](https://cmake.org/) ≥ 3.21 and [Ninja](https://ninja-build.org/) on your PATH
- [uv](https://github.com/astral-sh/uv) is recommended for dependency management, but `pip` works just as well

Clone the repository, initialise the `fuzzycoco` submodule, then build and install in editable mode with uv:

```bash
git clone https://github.com/CI4CB-lab/fuzzycocopython.git
cd fuzzycocopython
git submodule update --init --recursive

uv venv
source .venv/bin/activate
uv pip install -e .

```

If you prefer the standard tooling, create a virtual environment manually and install with `pip`:

```bash
python -m venv .venv
source .venv/bin/activate

pip install -e .
```

When you only need the published bindings and not the repository, install straight from GitHub:

```bash
pip install git+https://github.com/CI4CB-lab/fuzzycocopython.git
```

For development tasks (tests, linting, docs) install the optional toolchain:

```bash
uv pip install -e '.[dev]'
```

The build compiles the bundled C++ bindings. Refer to the
[`fuzzycoco` project](https://github.com/CI4CB-lab/fuzzycoco) for background on the engine itself.

## Quick start

```python
import pandas as pd
from sklearn.datasets import load_iris
from fuzzycocopython import FuzzyCocoClassifier

data = load_iris(as_frame=True)
clf = FuzzyCocoClassifier(random_state=0)
clf.fit(data.data, data.target)

preds = clf.predict(data.data)
score = clf.score(data.data, data.target)

print(f"Accuracy: {score:.3f}")
print(clf.rules_df_.head())
```

The estimators now expose scikit-learn style hyper-parameters for direct tuning:

```python
from fuzzycocopython import FuzzyCocoClassifier

model = FuzzyCocoClassifier(nb_rules=10, nb_sets_in=3, random_state=42)
model.fit(X, y)
preds = model.predict(X)
```

Bit widths for variable and set indices are automatically derived from the training data. Override them with `nb_bits_vars_in`, `nb_bits_sets_in`, `nb_bits_vars_out`, or `nb_bits_sets_out` when you need full manual control.

For a guided tour, open `demo.ipynb`. Additional usage examples live in `tests/test_fuzzycocopython.py`.

## Documentation

Full API documentation is available at [CI4CB-lab.github.io/fuzzycocopython](https://CI4CB-lab.github.io/fuzzycocopython/).
To build the docs locally run:

```bash
uv pip install -e '.[docs]'
uv run sphinx-build -W -b html docs docs/_build/html
```

## Pre-commit hooks

Install and activate the provided hooks (Ruff lint/format, mypy, general hygiene) once per clone:

```bash
uv run pre-commit install
```

Run them against the full tree when needed:

```bash
uv run pre-commit run --all-files
```


## License

This fuzzycoco software is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
