polyview
polyview is a Python library for multi-view learning, providing a consistent API for multi-view clustering, embedding, and fusion methods. It allows you to easily build pipelines that combine native multi-view estimators with single-view sklearn tools, while keeping track of per-view data and predictions.
Documentation is available at: https://gwendal-debaussart.github.io/polyview/
Installation
Install from PyPI:
pip install polyview
Quick start
The snippet below demonstrates four common workflows:
- native multi-view clustering,
- early fusion into single-view clustering,
- per-view sklearn models followed by late fusion,
- imputation of missing views.
import numpy as np
import polyview as pv
from polyview.dataset.make_multiview_gaussian import make_multiview_gaussian
from sklearn.cluster import KMeans as SKKMeans
from sklearn.preprocessing import StandardScaler
# Synthetic multiview dataset
mvd = make_multiview_gaussian(
n_samples=200,
n_features=20,
n_views=3,
centers=4,
random_state=0,
)
mvd.view_names = ["audio", "vision", "imu"]
# 1) Native multiview clustering
mv_model = pv.cluster.MultiViewKMeans(n_clusters=4, random_state=0)
mv_labels = mv_model.fit_predict(mvd)
print("MV labels:", mv_labels.shape)
# 2) Early fusion + single-view estimator
X_fused = pv.fusion.NormalizedFusion().fit_transform(mvd)
sv_model = SKKMeans(n_clusters=4, random_state=0)
sv_labels = sv_model.fit_predict(X_fused)
print("Fused shape:", X_fused.shape)
# 3) Per-view sklearn model + late fusion
# PolyPipeline runs one cloned SK estimator per view when final step is single-view.
pipe = pv.PolyPipeline(
steps=[
("scale", StandardScaler()),
("kmeans", SKKMeans(n_clusters=4, random_state=0)),
]
)
labels_by_view = pipe.fit_predict(mvd.views) # list of label vectors
late = pv.fusion.MajorityVote(weights=[0.2, 0.5, 0.3], tie_break="first")
late_labels = late.fit_predict(labels_by_view)
print("Late-fused labels:", late_labels.shape)
# 4) Missing views
# Views are incomplete when a modality was never acquired for a sample;
# missing entries are encoded as NaN.
incomplete, mask = pv.simulate_missing_views(mvd, missing_rate=0.2, random_state=0)
print("Missing rate per view:", pv.missing_rate(incomplete))
completed = pv.KNNViewImputer(n_neighbors=5).fit_transform(incomplete)
imputed_labels = pv.cluster.MultiViewKMeans(n_clusters=4, random_state=0).fit_predict(completed)
print("Labels from imputed views:", imputed_labels.shape)
Additional examples are available in the documentation: https://gwendal-debaussart.github.io/polyview/examples/
Contributing
Contributions are very welcome! If you plan to contribute, please see the CONTRIBUTING guidelines.
⚖️ License
GNU General Public License. See LICENSE for details.
Metadata
Release files for polyview 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| polyview-0.1.0.tar.gz | 99.4 kB | Details |
Release files / polyview-0.1.0.tar.gz
| Download URL | polyview-0.1.0.tar.gz |
|---|---|
| Size | 99.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6eaa8f52390510d9bcb74db5a09f88913b97c1e73f0103765540ac9fe6f6e4b4
|
|
BLAKE2b-256 checksum How to use checksums |
c375e0848bc5984416c1bc543f8e2ab86ebd1c13f9dec64587a6e40571ec11b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|