Metadata-Version: 2.4
Name: psann
Version: 0.9.17
Summary: PSANN: Parameterized Sine-Activated Neural Networks (sklearn-style, PyTorch backend)
Project-URL: Homepage, https://github.com
Project-URL: Repository, https://github.com
Project-URL: Issues, https://github.com
Project-URL: Documentation, https://github.com
Author: Nicholas Milinkovich
License: MIT License
        
        Copyright (c) 2025 Your Name
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
License-File: LICENSE
Keywords: classification,neural-networks,pytorch,regression,sine,siren,sklearn,time-series
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Requires-Dist: numpy>=1.23
Requires-Dist: torch>=2.1
Provides-Extra: dev
Requires-Dist: black>=24.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.5.0; extra == 'dev'
Provides-Extra: sklearn
Requires-Dist: scikit-learn<1.5,>=1.2; extra == 'sklearn'
Provides-Extra: viz
Requires-Dist: matplotlib>=3.7; extra == 'viz'
Description-Content-Type: text/markdown

# PSANN - Parameterized Sine-Activated Neural Networks

Sklearn-style estimators built on PyTorch that use learnable sine activations, optional persistent state, and shared helpers for episodic (HISSO) training.

Quick links:
- API reference: `docs/API.md`
- Technical design notes: `TECHNICAL_DETAILS.md`
- Scenario walkthroughs: `docs/examples/README.md`

## Installation

```bash
python -m venv .venv
.\.venv\Scripts\Activate.ps1   # Windows PowerShell
# source .venv/bin/activate     # macOS/Linux
pip install --upgrade pip
pip install -e .                # editable install from source
```

Extras defined in `pyproject.toml`:
- `psann[sklearn]`: adds scikit-learn for real BaseEstimator mixins and metrics
- `psann[viz]`: plotting helpers used in notebooks/examples
- `psann[dev]`: pytest, ruff, black

Need pre-pinned builds (e.g. on Windows or air-gapped envs)? Use the compatibility constraints:

```bash
pip install -e . -c requirements-compat.txt
```

`pyproject.toml` is the authoritative dependency list. `requirements-compat.txt` mirrors the newest widely available wheels for NumPy, SciPy, and scikit-learn when you need lockstep installs.

## NumPy 2.0 status

- Core PSANN modules run cleanly on NumPy 2.0; no removed aliases (e.g. `np.bool`, `np.int`) are referenced.
- The base install now depends on `numpy>=1.23` with no upper cap. Use `requirements-compat.txt` when you need the older NumPy 1.26 wheels for legacy environments.
- The optional `psann[sklearn]` extra still uses scikit-learn<1.5; those wheels currently target NumPy 1.x. Install scikit-learn>=1.5 when available or stick to the compatibility constraints if you rely on that extra.

## Quick Start

### Supervised regression

```python
import numpy as np
from psann import PSANNRegressor

rs = np.random.RandomState(42)
X = np.linspace(-4, 4, 1000, dtype=np.float32).reshape(-1, 1)
y = 0.8 * np.exp(-0.25 * np.abs(X)) * np.sin(3.5 * X)

model = PSANNRegressor(
    hidden_layers=2,
    hidden_units=64,
    epochs=200,
    lr=1e-3,
    early_stopping=True,
    patience=20,
    random_state=42,
)
model.fit(X, y, verbose=1)
print("R^2:", model.score(X, y))
```

### Supervising extras outputs

Append extra columns to `y` or pass them separately. Extra heads are scheduled automatically when `extras>0`.

```python
extras = np.stack([np.cos(X[:, 0]), np.sin(X[:, 0])], axis=1).astype(np.float32)
y_with_extras = np.concatenate([y[:, None], extras], axis=1)

model = PSANNRegressor(hidden_layers=2, hidden_units=64, extras=2)
model.fit(X, y_with_extras, verbose=1)
```

For streaming/time-series, LSM preprocessors, segmentation heads, and HISSO workflows, head to `docs/examples/README.md`.

## Feature Highlights

- Learnable sine activations (`SineParam`) with amplitude, frequency, and decay bounds
- Shared `_fit` helper powering PSANN, residual PSANN, and language-model estimators
- Optional predictive extras with automatic target detection and rollout utilities
- Stateful controllers for streaming inference with warm-start and reset policies
- Convolutional variants that preserve spatial structure and support per-element outputs
- HISSO episodic training with reward hooks, supervised warm starts, and extras scheduling

## Contributing

- Run `pip install -e .[dev]` and then `pytest` / `ruff check .`
- Format code with `black` and keep docstrings ASCII unless a file already uses Unicode
- See open TODO items in `TODO.txt`
