View Construction

Random Gaussian Projection

mvlearn.construct.random_gaussian_projection(X, n_views=1, n_components='auto', eps=0.1, random_state=None)[source]

Random Gaussian Projection method for constructing multiple views. Each view is constructed using sklearn's random Gaussian projection. This wrapped version has an option to specify the number of views you want to generate. Random_state is also only set once in the function (not per view).

Parameters:

X : array-like matrix, shape = (n_samples, n_cols)

The input samples.

n_views : int, float optional (default = 1)

Number of views to construct.

n_components: int, string optional (default = "auto")

Dimensionality of target projection space (see sklearn for details)

eps: strictly positive float, optional (default = 0.1)

Parameter for controlling quality of embedding when n_components = "auto" (see sklearn for details)

random_state: int or None (default = None)

Sets random state using np.random.seed

Returns:

views : list of array-like matrices

List of constructed views.
  • length: n_views
  • each view has shape (n_samples, n_features)

Notes

From an implementation perspective, this wraps GaussianRandomProjection from sklearn.random_projection and creates multiple projections.

Examples

>>> from mvlearn.construct import random_gaussian_projection
>>> import numpy as np
>>> single_view_data = np.random.rand(1000, 50)
>>> # Project to 10 components
>>> multi_view_data = random_gaussian_projection(single_view_data,
...                                              n_views=3,
...                                              n_components=10)
>>> print(len(multi_view_data))
3
>>> print(multi_view_data[0].shape)
(1000, 10)

Read more about sklearn's implementation here.

Random Subspace Method

mvlearn.construct.random_subspace_method(X, n_features=None, n_views=1)[source]

Random Subspace Method [1] for constructing multiple views. Each view is constructed by randomly selecting n_features (columns) from X. All unselected features are set to 0.

Parameters:

X : array-like matrix, shape = (n_samples, n_cols)

The input samples.

n_features : int, float

Number (or proportion, if float) of features to randomly select.
  • If int, then consider n_features as number of columns to select.
  • If float, then consider n_features*n_cols as number of columns to select.

n_views : strictly positive int, float optional (default = 1)

Number of views to construct.

Returns:

views : list of array-like matrices

List of constructed views.
  • length: n_views
  • each view has shape (n_samples, n_features)

References

[1]Ho, Tin Kam. "The random subspace method for constructing decision forests." IEEE transactions on pattern analysis and machine intelligence 20.8 (1998): 832-844.

Examples

>>> from mvlearn.construct import random_subspace_method
>>> import random
>>> import numpy as np
>>> # Random integer data for compressed viewing
>>> np.random.seed(1)
>>> random.seed(1)
>>> single_view_data = np.random.randint(low=1, high=10, size=(4, 5))
>>> multi_view_data = random_subspace_method(single_view_data,
...                                          n_features=3, n_views=2)
>>> print(multi_view_data[0])
[[6 9 0 0 1]
 [2 8 0 0 5]
 [6 3 0 0 5]
 [8 8 0 0 1]]
>>> print(multi_view_data[1])
[[6 0 6 1 0]
 [2 0 7 3 0]
 [6 0 5 3 0]
 [8 0 2 8 0]]