View splitter

ViewSplitter cuts a single matrix into consecutive column blocks, one per view. It is the inverse of ConcatFusion and of to_numpy().

Placed first in a PolyPipeline, it lets a multi-view workflow receive its views as one 2-D array, which is what scikit-learn’s model-selection tools expect, since they split samples along the first axis. This makes GridSearchCV and cross_val_score() usable on a multi-view pipeline.

ViewSplitter.n_views reports how many views n_features describes, or 0 when it is unset. It is kept out of the listing below: n_views is the word every other docstring uses inside shape descriptions such as ndarray of shape (n_views,), and a documented attribute of that name turns each of them into a link to this page.

class polyview.augmentation.view_splitter.ViewSplitter(*args: Any, **kwargs: Any)

Bases: BaseEstimator

Split a single matrix into consecutive column blocks, one per view.

This is the inverse of ConcatFusion and of MultiViewDataset.to_numpy(). Placed first in a PolyPipeline, it lets a multi-view workflow receive its views as one 2-D array, which is what scikit-learn’s model-selection tools (e.g. GridSearchCV or cross_val_score()) expect, since they split samples along the first axis.

Parameters:
  • n_features (sequence of int or None, default=None) – Number of columns of each view, in order. Must sum to the number of columns of the input.

  • view_names (sequence of str, optional) – Names for each view. If None, defaults to [“view_0”, “view_1”, …].

split_indices_

Column indices at which the input is split.

Type:

ndarray

n_features_in_

Number of columns of the input.

Type:

int

n_views_in_

Number of views produced.

Type:

int

view_names_

Names of each view.

Type:

list of str

Examples

>>> import numpy as np
>>> from polyview.augmentation.view_splitter import ViewSplitter
>>> X = np.random.rand(100, 9)
>>> mvd = ViewSplitter(n_features=[5, 4]).fit_transform(X)
>>> [v.shape for v in mvd.views]
[(100, 5), (100, 4)]
fit(X, y=None) → ViewSplitter
fit_transform(X, y=None) → MultiViewDataset
transform(X) → MultiViewDataset