Tools for linear dimension reduction
Project description
shaded
shaded provides tools for linear spectral feature extraction and dimension reduction, with a focus on fast, interpretable projections for machine learning and signal processing.
Features
- PseudoLda: Fast, approximate Linear Discriminant Analysis (LDA) using class centers.
- PseudoPca: Fast, approximate Principal Component Analysis (PCA) using random hyperplanes.
- PairwiseLda: LDA projections for every pair of classes.
- Chained Spectral Projectors: Compose multiple projection methods in sequence.
- Band Projection Matrix: Utilities for frequency band bucketing and projection.
- Linear Algebra Utilities: Null space, projection, and residue computations.
Installation
pip install shaded
Usage Examples
PseudoLda: Fast LDA-like Projection
from shaded.pseudo_lda import PseudoLda
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
plda = PseudoLda(n_components=2)
plda.fit(X, y)
X_proj = plda.transform(X)
print(X_proj.shape) # (n_samples, 2)
PseudoPca: Fast PCA-like Projection
from shaded.pseudo_pca import PseudoPca
ppca = PseudoPca(n_components=2)
ppca.fit(X)
X_proj = ppca.transform(X)
print(X_proj.shape) # (n_samples, 2)
PairwiseLda: LDA for All Class Pairs
from shaded.pair_wise_lda import PairwiseLda
pwlda = PairwiseLda(n_components=2)
pwlda.fit(X, y)
X_proj = pwlda.transform(X)
print(X_proj.shape)
Chained Spectral Projectors
Chain multiple projections (e.g., PCA followed by LDA):
from shaded.chained_spectral_projector import GeneralProjectionLearner
chain = (
{'type': 'pca', 'args': {'n_components': 3}},
{'type': 'lda', 'args': {'n_components': 2}},
)
gpl = GeneralProjectionLearner(chain=chain)
X_proj = gpl.fit_transform(X, y)
print(X_proj.shape) # (n_samples, 5)
Band Projection Matrix
Create frequency band buckets and projection matrices:
from shaded.band_projection_matrix import make_band_proj_matrix
proj_matrix = make_band_proj_matrix(n_buckets=5, n_freq=20)
print(proj_matrix.shape) # (5, 20)
API Overview
PseudoLda: Fast LDA-like projection for well-separated clusters.PseudoPca: Fast PCA-like projection using random hyperplanes.PairwiseLda: LDA projections for all class pairs.GeneralProjectionLearner: Chain and compose projections (PCA, LDA, etc.).band_projection_matrix: Create frequency band buckets and projection matrices.linalg_utils: Linear algebra helpers (null space, projection, residue).
Testing
Unit tests are provided for core linear algebra and projection utilities. To run tests:
pytest shaded/tests/
License
[Specify your license here]
Let me know if you want to add more advanced examples or further API details!
Project details
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 shaded-0.1.5.tar.gz.
File metadata
- Download URL: shaded-0.1.5.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bcc54c728de97730b6f36f197e15e615c9539df34bc8570da43b375a5d61fdb
|
|
| MD5 |
b5435fc1deae30bd85055691232d8b38
|
|
| BLAKE2b-256 |
073cd890121bb279038d3007cf64d432269597035d7794d23b9efa3a37f337d5
|
File details
Details for the file shaded-0.1.5-py3-none-any.whl.
File metadata
- Download URL: shaded-0.1.5-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f55a29aa9fa3406b0be614aac2a06efd308d8b404aa923a51f4bbde8f089a86e
|
|
| MD5 |
00d35b3c1495423d26b5b4ec7db35197
|
|
| BLAKE2b-256 |
0eec18f85441b8a0014dc27d16539da2916e85497dd017675d569809efaa401f
|