Early Fusion

Early fusion is a method of combining multiple data sources at the feature level. In this approach, features from different modalities (e.g., text, images, audio) are concatenated or merged together before being fed into a machine learning model. This allows the model to learn from the combined feature space, potentially capturing interactions between different modalities.

Early fusion strategies — combine views before any learning.

Classes

ConcatFusion horizontal concatenation of all views WeightedFusion per-view weighted concatenation NormalizedFusion z-score each view before concatenating WeightedSumFusion per-view weighted sum of normalized views, after a kernel transformation WeightedProductFusion per-view weighted product of normalized views, after a kernel transformation

class polyview.fusion.early.ConcatFusion(*args: Any, **kwargs: Any)

Bases: BaseMultiViewTransformer

Fuse views by horizontal concatenation.

Output shape is (n_samples, sum(n_features_i)).

Parameters:

n_views (int or None, default=None) – Expected number of views. None accepts any count.

n_views_in_
Type:

int

n_features_in_
Type:

list of int

n_features_out_

Total number of output features after concatenation.

Type:

int

Examples

>>> import numpy as np
>>> from polyview.fusion.early import ConcatFusion
>>> X1 = np.random.rand(50, 4)
>>> X2 = np.random.rand(50, 6)
>>> fused = ConcatFusion().fit_transform([X1, X2])
>>> fused.shape
(50, 10)
fit(views: List, y=None) ConcatFusion

Fit the model from a list of views.

Parameters:
  • views (list of array-like of shape (n_samples, n_features_i))

  • y (ignored for unsupervised methods)

Return type:

self

transform(views: List) numpy.ndarray

Apply the fitted transformation to views.

Parameters:

views (list of array-like)

Return type:

ndarray of shape (n_samples, n_components)

class polyview.fusion.early.NormalizedFusion(*args: Any, **kwargs: Any)

Bases: BaseMultiViewTransformer

Fuse views after per-view z-score normalization.

Each view is standardized (zero mean, unit variance per feature) independently before concatenation. This prevents views with larger numeric scales from dominating the fused representation — almost always a better default than plain ConcatFusion.

Parameters:
  • weights (list of float or None, default=None) – Optional per-view scalar weights applied after normalization.

  • eps (float, default=1e-8) – Small constant added to the denominator to avoid division by zero for constant features.

  • n_views (int or None, default=None)

means_

Per-feature means computed during fit.

Type:

list of ndarray of shape (n_features_i,)

stds_

Per-feature standard deviations (clipped to eps).

Type:

list of ndarray of shape (n_features_i,)

weights_
Type:

ndarray of shape (n_views,)

Examples

>>> fused = NormalizedFusion().fit_transform([X1, X2])
>>> fused.mean(axis=0)          # ≈ 0 for every feature
>>> fused.std(axis=0)           # ≈ 1 for every feature
fit(views: List, y=None) NormalizedFusion

Fit the model from a list of views.

Parameters:
  • views (list of array-like of shape (n_samples, n_features_i))

  • y (ignored for unsupervised methods)

Return type:

self

transform(views: List) numpy.ndarray

Apply the fitted transformation to views.

Parameters:

views (list of array-like)

Return type:

ndarray of shape (n_samples, n_components)

class polyview.fusion.early.WeightedFusion(*args: Any, **kwargs: Any)

Bases: BaseMultiViewTransformer

Fuse views by weighted concatenation.

Each view is scaled by a scalar weight before concatenation. Useful when you have prior knowledge that some views are more informative or reliable than others.

Parameters:
  • weights (list of float or None, default=None) – One weight per view. Weights do not need to sum to 1 — they are applied as-is (view_i * weight_i). When None, all weights are set to 1.0 (equivalent to ConcatFusion).

  • n_views (int or None, default=None)

weights_

The weights actually applied (after length validation).

Type:

ndarray of shape (n_views,)

Examples

>>> fused = WeightedFusion(weights=[1.0, 0.5]).fit_transform([X1, X2])
fit(views: List, y=None) WeightedFusion

Fit the model from a list of views.

Parameters:
  • views (list of array-like of shape (n_samples, n_features_i))

  • y (ignored for unsupervised methods)

Return type:

self

transform(views: List) numpy.ndarray

Apply the fitted transformation to views.

Parameters:

views (list of array-like)

Return type:

ndarray of shape (n_samples, n_components)