cca_zoo.visualisation
.ExplainedVarianceDisplay#
- class cca_zoo.visualisation.ExplainedVarianceDisplay(explained_variance_train, explained_variance_test=None, ratio=True, view_labels=None, **kwargs)[source]#
Bases:
object
Display the explained variance of the latent variables of the representations.
- Parameters:
explained_variance_train (np.ndarray) – The explained variance of the train data.
explained_variance_test (np.ndarray) – The explained variance of the test data.
ratio (bool) – Whether to plot the ratio of explained variance or not.
**kwargs (dict) – Keyword arguments to be passed to the seaborn lineplot.
- figure_#
The figure of the plot.
- Type:
matplotlib.pyplot.figure
Examples
>>> from cca_zoo.visualisation import ExplainedVarianceDisplay >>> import matplotlib.pyplot as plt >>> import numpy as np >>> from cca_zoo.linear import _MCCALoss >>> >>> # Generate Sample Data >>> # -------------------- >>> X = np.random.rand(100, 10) >>> Y = np.random.rand(100, 10) >>> >>> # Splitting the data into training and testing sets >>> X_train, X_test = X[:50], X[50:] >>> Y_train, Y_test = Y[:50], Y[50:] >>> >>> representations = [X_train, Y_train] >>> test_views = [X_test, Y_test] >>> >>> # Train an _MCCALoss Model >>> # ------------------- >>> mcca = _MCCALoss(latent_dimensions=2) >>> mcca.fit(representations) >>> >>> # %% >>> # Plotting the Explained Variance >>> # --------------------------------- >>> ExplainedVarianceDisplay.from_estimator(mcca, representations, test_views=test_views).plot() >>> plt.show()