semvec/pypi-packages huggingface dataset:
nirviz 0.1.4
Visualisation tool for the Neuromorphic Intermediate Representation
Requires Python: >=3.9

# Neuromorphic Intermediate Representation Visualisation Tool

Turn your NIR definitions into a nice graph, the original publication serving as a template.

Customise your node colour preferences in [style.yml](nirviz/style.yml), and quickly generate graphs from your neuromorphic networks.

This work is in progress.

## Running Example (Jupyter Notebook)
By running the following code (from a notebook),
```python
import nir
import nirviz
import numpy as np


a = np.random.randn(2)
ir = nir.NIRGraph(
    nodes={
        "input": nir.Input(input_type=np.array([2])),
        "affine1": nir.Affine(weight=np.zeros((2,2)), bias=False),
        "cu1": nir.CubaLIF(tau_mem=a, tau_syn=a, r=a, v_leak=a, v_threshold=a, v_reset=a),
        "affine_rec": nir.Affine(weight=np.zeros((2,2)), bias=False),
        "affine2": nir.Affine(weight=np.zeros((2,2)), bias=False),
        "cu2": nir.CubaLIF(tau_mem=a, tau_syn=a, r=a, v_leak=a, v_threshold=a, v_reset=a),
        "output": nir.Output(output_type=np.array([2]))
    },
    edges=[("input", "affine1"), ("affine1", "cu1"), ("affine_rec", "cu1"),  ("cu1", "affine_rec"), ("cu1", "affine2"), ("affine2", "cu2"), ("cu2", "output")])

viz = nirviz.visualize(ir)
viz.show()
```

You would get the following visualisation

<picture>
<img alt="nirviz output" src="https://github.com/open-neuromorphic/nirviz/raw/main/img/srnn.png">
</picture>

Similar to Figure 3 of the publication.

<picture>
<img alt="Figure 3 of NIR paper for comparison to output" src="https://github.com/open-neuromorphic/nirviz/raw/main/img/fig3.png">
</picture>

## Running example (CLI)
To convert a saved NIR graph (e.g. srnn.nir) to a PNG or SVG, you can use one of the following commands:
```bash
python -m nirviz srnn.nir              # SVG -> stdout
python -m nirviz srnn.nir img/srnn.png # PNG -> file
python -m nirviz srnn.nir img/srnn.svg # SVG -> file
```

## Customising the style
You can customise the style you see via the *style file*.
### Style file location
The style file is defined in YAML. You can find the default location by running:
```python
import nirviz
print(f"nirviz style file location: {nirviz.visualize.default_style_file()}")
```

or by passing your own `style.yml`:
```python
import nirviz
viz = nirviz.visualize(nir_graph, style_file="style.yml")
viz.show()
```
```bash
python -m nirviz --yaml './style.yml' srnn.nir
```

### Style file format
The format currently only supports setting node attributes. The node attributes correspond to [Graphviz node attributes](https://graphviz.org/docs/nodes/). An example file would contain:

```yaml
node-categories:
    category-name: # User defined
        patterns: ["Affine", "IF"]
        attributes:
            # Corresponds to node attributes of graphviz
            # https://graphviz.org/docs/nodes/
            color: "red"
            style: "filled"
            shape: "box"
```

Which would paint all "Affine" and "IF" NIR nodes red.
r3alai 0.1.3
A Python library for Random Set Neural Networks with uncertainty estimation
Requires Python: >=3.8

# R3ALAI

Python SDK for Random Set Neural Networks (RSNN): uncertainty estimation, conformal prediction, and active learning. Built to add RSNN benefits (sample efficiency, robustness, reliability) to ML workflows.

## Install
- Base: `pip install r3alai`
- With vision backbones: `pip install 'r3alai[vision]'`
- With YOLO: `pip install 'r3alai[yolo]'`

Requires Python 3.8+ and PyTorch.

## What it provides
- `r3alai.models`: `RSNNClassifier` — RSNN head on a backbone (torchvision or custom `nn.Module`).
- `r3alai.conformal`: `ConformalPredictor` — confidence sets with distribution-free coverage after calibration.
- `r3alai.active_learning`: `ActiveLearner` — entropy/credal querying and simple disagreement mode.
- `r3alai.utils`: `RSNNYOLOWrapper`, `YOLOFeatureExtractor` — plug RSNN uncertainty into YOLOv8.

## How to use (high-level)
1) Create an RSNN model
- Pick a backbone: `"resnet50"`, `"mobilenet_v2"`, `"efficientnet_b0"`, or use a custom backbone.
- Set `n_classes` (one-hot labels expected). Optional `alpha`/`beta` regularization.

2) Train
- Call `fit(X, y, ...)` with tensors/ndarrays; early stopping and LR scheduling are included.

3) Predict with uncertainty
- Call `predict(..., return_uncertainty=True)` to get predictions, pignistic entropy, and credal width.

## Conformal prediction
1) Wrap a trained RSNN with `ConformalPredictor(confidence_level=0.9/0.95)`.
2) Calibrate on a held-out split (features and one-hot labels).
3) Use `predict` for confidence sets; `get_coverage` to measure empirical coverage.

## Active learning
1) Construct `ActiveLearner(model, uncertainty_measure="entropy"|"credal")`.
2) Provide an unlabeled pool to `query` to select samples and indices for annotation.

## YOLO integration (optional)
1) Install extras: `r3alai[yolo]`.
2) Initialize `RSNNYOLOWrapper(yolo_model_path, n_classes)`.
3) Train with your DataLoaders; optionally calibrate conformal and then predict with uncertainty or confidence sets.

## Custom backbones and frameworks
- Custom `nn.Module`: set `base_model="custom"`, assign your module to `rsnn_model.base_model`, then call `set_belief_layer(feature_dim)`.
- Hugging Face models: adapt outputs to a 512-dim feature vector and connect as a custom backbone.

## Tips
- Keep a small calibration split to enable conformal coverage.
- Start active learning with entropy querying; try disagreement for harder pools.
- For detection, first freeze the YOLO backbone and train only the RSNN head.

## Support
- See docstrings on `RSNNClassifier`, `ConformalPredictor`, `ActiveLearner`, and `RSNNYOLOWrapper`.
- Report issues and requests on GitHub Issues.

## License
MIT
LightningBO 0.1.2
LightningBO: JAXベースの高速ベイジアン最適化ライブラリ。ハイパーパラメータ探索やマーケティング最適化に最適。EI/PI/UCB/LCB獲得関数、ガウス過程、JIT高速化、メモリ効率設計。
Requires Python: >=3.12
Keywords: bayesian optimization, jax, hyperparameter, machine learning, marketing mix

# LightningBO

LightningBOは、ベイズ最適化（Bayesian Optimization）を簡単に実装・拡張できるPythonライブラリです。
本ライブラリは、ブラックボックス関数の最適化やハイパーパラメータ探索など、試行回数を抑えつつ効率的に最適解を見つけたい場面で活用できます。

## 特徴

- JAXベースの高速な計算
- 連続・離散パラメータ両対応
- 期待値改善（EI）などの獲得関数
- 拡張性の高い設計

## 使い方例

```python
import LightningBO.bayesian_optimization as bo
import LightningBO.bayesian_core as bc

# 最適化したい関数
def f(x):
	return x**2 - 4*x + 5

# 探索空間の定義
domain = {"x": bc.Continuous(-10, 10)}

# Optimizerの作成
optimizer = bo.Optimizer(domain=domain, maximize=False)

# 初期点
params = {"x": [0.0, 2.0, 5.0]}
ys = [f(x) for x in params["x"]]
state = optimizer.init(ys, params)

# 最適化ループ
for step in range(20):
	new_params = optimizer.sample(None, state)
	y = f(**new_params)
	state = optimizer.fit(state, y, new_params)

print("最適値:", state.best_score)
print("最適パラメータ:", state.best_params)
```

## 主な用途

- 機械学習モデルのハイパーパラメータ最適化
- 実験・シミュレーションのパラメータ探索
- その他ブラックボックス関数の最適化