Metadata-Version: 2.4
Name: nwf-core
Version: 0.2.1
Summary: Core library for Neural Weight Fields (NWF) - charge, field, metrics, indices
Author: Belousov Roman Sergeevich
License: MIT
Project-URL: Homepage, https://github.com/romero19912017-ui/nwf-core
Project-URL: Repository, https://github.com/romero19912017-ui/nwf-core
Project-URL: Documentation, https://romero19912017-ui.github.io/nwf-core/
Keywords: machine-learning,continual-learning,neural-weight-fields,uncertainty
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.21
Requires-Dist: scipy>=1.7
Requires-Dist: scikit-learn>=1.0
Provides-Extra: faiss
Requires-Dist: faiss-cpu>=1.7; extra == "faiss"
Provides-Extra: torch
Requires-Dist: torch>=1.10; extra == "torch"
Provides-Extra: docs
Requires-Dist: sphinx>=5.0; extra == "docs"
Requires-Dist: furo>=2023.0; extra == "docs"
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Provides-Extra: all
Requires-Dist: nwf-core[dev,docs,faiss,torch]; extra == "all"

# nwf-core

[![PyPI version](https://badge.fury.io/py/nwf-core.svg)](https://pypi.org/project/nwf-core/)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![Tests](https://github.com/romero19912017-ui/nwf-core/actions/workflows/test.yml/badge.svg)](https://github.com/romero19912017-ui/nwf-core/actions/workflows/test.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Core library for **Neural Weight Fields (NWF)** - charge, field, metrics, indices, calibration.

## Installation

```bash
pip install nwf-core
# With FAISS: pip install nwf-core[faiss]
# With VAE (torch): pip install nwf-core[torch]
# All: pip install nwf-core[all]
```

## Quick start

```python
import numpy as np
from nwf import Charge, Field, mahalanobis_symmetric

# Create charges
c1 = Charge(z=np.array([0.0, 0.0]), sigma=np.array([0.1, 0.1]))
c2 = Charge(z=np.array([1.0, 1.0]), sigma=np.array([0.1, 0.1]))

# Build field and search
field = Field()
field.add([c1, c2], labels=[0, 1])
distances, indices, labels = field.search(c1, k=2)
```

See [documentation](https://romero19912017-ui.github.io/nwf-core/) and [nwf-vision](https://github.com/romero19912017-ui/nwf-vision) for examples.

## Components

- **Charge**: `(z, sigma)` - center and diagonal covariance
- **Field**: Container for charges with add/remove/search
- **Metric**: mahalanobis_symmetric, euclidean, cosine
- **Index**: BruteForceIndex, FAISSIndex (l2, cosine, ip; optional rerank with Mahalanobis)
- **Calibration**: AgreementRatio, PlattScaler
- **Encoders**: VAEEncoder (optional, requires torch)

## Development

```bash
pip install -e ".[dev,docs]"
pre-commit install   # optional: run checks before commit
make lint            # black, isort, flake8
make format          # auto-format
make html            # build Sphinx docs -> docs/_build/html
```

## License

MIT
