PyLWL: A Python Framework for Locally Weighted Learning
Project description
PyLWL: A Python Framework for Locally Weighted Learning
📌 Overview
PyLWL is an open-source Python library that provides a unified, extensible, and user-friendly implementation of Locally Weighted Learning (LWL) algorithms for supervised learning. It implements differentiable and gradient-descent-based local models for both classification and regression tasks.
Features
- 📌 GdLwClassifier: Local weighted classifier using logistic regression with support for binary and multiclass classification.
- 📌 GdLwRegressor: Local weighted regressor using linear regression optimized with MSE loss.
- 📌 LwClassifier and LwRegressor: Local weighted classifier/regressor with a fixed kernel.
- 🧠 Supports any differentiable kernel function (e.g., Gaussian, Epanechnikov).
- ⚙️ Built with PyTorch, and fully compatible with Scikit-Learn pipeline and metrics.
- 🔧 Configurable optimizer (
Adam,SGD, etc.) and hyperparameters. - 🔍 Built-in support for model evaluation and scoring.
📖 Citation Request
Please include these citations if you plan to use this library:
@software{thieu20250517PyLWL,
author = {Nguyen Van Thieu},
title = {PyLWL: A Python Framework for Locally Weighted Learning},
month = June,
year = 2025,
doi = {10.6084/m9.figshare.29089784},
url = {https://github.com/thieu1995/PyLWL}
}
📦 Installation
Install the latest version from PyPI:
pip install pylwl
Verify installation:
$ python
>>> import pylwl
>>> pylwl.__version__
🚀 Quick Start
Classification
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from pylwl import LwClassifier
# Load data
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
# Train LVQ1 model
model = LwClassifier(kernel="gaussian", tau=1.0)
model.fit(X_train, y_train)
# Evaluate
y_pred = model.predict(X_test)
print("Accuracy:", model.score(X_test, y_test))
Regression
from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from pylwl import LwRegressor
X, y = fetch_california_housing(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
reg = LwRegressor(kernel='gaussian', tau=1.0)
reg.fit(X_train, y_train)
print("R2 score:", reg.score(X_test, y_test))
Please read the examples folder for more use cases.
📚 Documentation
Documentation is available at: 👉 https://pylwl.readthedocs.io
You can build the documentation locally:
cd docs
make html
🧪 Testing
You can run unit tests using:
pytest tests/
🤝 Contributing
We welcome contributions to PyLWL! If you have suggestions, improvements, or bug fixes, feel free to fork
the repository, create a pull request, or open an issue.
📄 License
This project is licensed under the GPLv3 License. See the LICENSE file for more details.
📎 Official channels
- 🔗 Official source code repository
- 📘 Official document
- 📦 Download releases
- 🐞 Issue tracker
- 📝 Notable changes log
- 💬 Official discussion group
Developed by: Thieu @ 2025
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylwl-0.2.0.tar.gz.
File metadata
- Download URL: pylwl-0.2.0.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b04484dce4c76d16fb77d4a985e05ace38501b4a1defd91307bdb76f6f63bd7
|
|
| MD5 |
53ca3bf73a0831dbfeb40d95efb14ea1
|
|
| BLAKE2b-256 |
130a0b4a9390ab6fa369ac3e4ec78da3b992effff6f77f39300aa3f95d90a758
|
Provenance
The following attestation bundles were made for pylwl-0.2.0.tar.gz:
Publisher:
publish-package.yml on thieu1995/PyLWL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylwl-0.2.0.tar.gz -
Subject digest:
9b04484dce4c76d16fb77d4a985e05ace38501b4a1defd91307bdb76f6f63bd7 - Sigstore transparency entry: 230318356
- Sigstore integration time:
-
Permalink:
thieu1995/PyLWL@c69fca61f87f07c7eeb8721591cc6ef9db27346c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/thieu1995
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@c69fca61f87f07c7eeb8721591cc6ef9db27346c -
Trigger Event:
release
-
Statement type:
File details
Details for the file pylwl-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pylwl-0.2.0-py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4269c2b78f13390363961c487d3713ca3a2f450609cc48a19b59c8fe9899384e
|
|
| MD5 |
041772db64582f3a07475eb924529756
|
|
| BLAKE2b-256 |
52031b14e269d05cab4aea700fb0b426f3c831e380e165cb39ad1591bec32cae
|
Provenance
The following attestation bundles were made for pylwl-0.2.0-py3-none-any.whl:
Publisher:
publish-package.yml on thieu1995/PyLWL
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylwl-0.2.0-py3-none-any.whl -
Subject digest:
4269c2b78f13390363961c487d3713ca3a2f450609cc48a19b59c8fe9899384e - Sigstore transparency entry: 230318363
- Sigstore integration time:
-
Permalink:
thieu1995/PyLWL@c69fca61f87f07c7eeb8721591cc6ef9db27346c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/thieu1995
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@c69fca61f87f07c7eeb8721591cc6ef9db27346c -
Trigger Event:
release
-
Statement type: