Metadata-Version: 2.4
Name: pan2
Version: 1.2.0
Summary: Complete runnable study examples for six FOML topics
Requires-Python: <3.13,>=3.10
Description-Content-Type: text/markdown
Requires-Dist: numpy==1.26.4
Requires-Dist: pandas==2.2.3
Requires-Dist: matplotlib==3.9.2
Requires-Dist: scikit-learn==1.5.2
Requires-Dist: opencv-python==4.10.0.84
Requires-Dist: tensorflow==2.16.2

# pan2 1.2.0

19 standalone programs for KNN, K-Means, neural networks, PCA, LDA and OpenCV, including scratch versions, a master import block, mixed-column CSV example, and an exam code-change guide.

## One import

```python
import pan2 as ps

X, y = ps.load_iris(return_X_y=True)
model = ps.KNeighborsClassifier(n_neighbors=5)
model.fit(X, y)
print(model.predict([[5.1, 3.5, 1.4, 0.2]]))

print(ps.np.array([1, 2, 3]))
print(ps.list_examples())
ps.run("knn_scratch", "--k", "7")
```

`ps.np`, `ps.pd`, `ps.plt`, `ps.tf`, `ps.cv2`, `ps.StandardScaler`, `ps.KMeans`, `ps.PCA`, `ps.LinearDiscriminantAnalysis`, dataset loaders, metrics and scratch functions are available. `import pas as ps` also works for compatibility. Use `ps.np` in place of bare `np`, or assign `np = ps.np` first. Dependencies load when their attributes are accessed.

## Install on multiple computers

This release is prepared for PyPI publication. Check https://pypi.org/project/pan2/ for its current public availability.

Install from PyPI when the release is available:

```sh
python -m pip install pan2
```

Before publication, extract the provided ZIP and run from its folder:

```sh
python -m pip install ./pan2-1.2.0-py3-none-any.whl
```

Both commands install all six topic dependencies including TensorFlow by default. No `[all]` extra is needed. Do not use the public command until your release is visible at https://pypi.org/project/pan2/ .

Use 64-bit Python 3.10–3.12; Python 3.12 is locally tested. Create a virtual environment with `python -m venv .venv`, then activate it with `.venv\Scripts\Activate.ps1` on Windows PowerShell or `source .venv/bin/activate` on macOS/Linux. Use Windows `py -3.12` or macOS/Linux `python3.12` if needed to select that Python version. Internet is needed to download dependencies.

## Run and export

```sh
pan2 list
pan2 doctor
pan2 run knn_scratch --k 7 --distance manhattan
pan2 run pca_scratch --components 2 --out pca.png
pan2 run nn_tensorflow --epochs 100
pan2 run nn_images --epochs 40
pan2 run opencv_basics --image photo.jpg --out processed.png
pan2 export my_codes
```

The `foml` command and `python -m foml_lab` also work. Export includes all 19 self-contained programs, `all_imports.py`, the alias modules, guides and sample CSV. It refuses to overwrite existing files. Run any exported program directly, e.g. `python my_codes/knn_scratch.py --k 7`. Alias modules require the installed package for the packaged-example `run` and scratch-function helpers.

## Included programs

| Topic | Programs |
|---|---|
| KNN | knn_sklearn, knn_scratch |
| K-Means | kmeans_sklearn, kmeans_scratch, both with elbow plots |
| Neural networks | nn_tensorflow, nn_scratch, nn_binary, nn_images, nn_onehot |
| PCA | pca_scratch, pca_numerical, pca_sklearn, pca_image_scratch, pca_image_sklearn, eigenfaces_scratch |
| LDA | lda_sklearn, lda_scratch |
| OpenCV | opencv_basics |
| Base CSV | base_csv |

## Versions, provenance and limits

NumPy 1.26.4, pandas 2.2.3, Matplotlib 3.9.2, scikit-learn 1.5.2, OpenCV 4.10.0.84 and TensorFlow 2.16.2 are pinned. Native dependencies require supported OS/CPU/Python; the wheel containing this project's Python code is platform-independent. Only this Apple Silicon Mac/Python 3.12 environment was executed; Windows/Linux and other Python versions were not live tested. CPU examples require no GPU setup. Some older CPUs cannot run TensorFlow; native Windows may need the Visual C++ Redistributable. Python 3.13/3.14 are unsupported by this release.

These implementations were recreated from the topic/program descriptions in the user's pasted conversation on 12 October 2026. The original PDF and `.py` files were not supplied, so these are not an exact recovery of those files or claimed scores. The 19 unchanged examples were executed successfully before the package rename; see the retained validation record and new packaging/API checks.

Built-in datasets work offline after dependencies are installed. The sample CSV is explicitly synthetic preprocessing demo data. Eigenfaces defaults to digits as a PCA matrix demonstration; supply same-sized real face images with `--folder` for an actual face-image example. No face recognition accuracy is claimed. Figures save to PNG; OpenCV colour display uses BGR→RGB. Accuracy varies; 40-epoch Iris TensorFlow examples reached 0.7667 locally, while digits reached 0.9750. Increase epochs and tune using validation data, not the test set.

Official references: https://packaging.python.org/en/latest/tutorials/packaging-projects/ and https://www.tensorflow.org/install/pip .
