cca_zoo.visualisation

class cca_zoo.visualisation.CorrelationHeatmapDisplay(train_correlations, test_correlations)[source]

Bases: object

Correlation Heatmap Display

Heatmap of the correlations between the latent variables of the views.

Parameters:
  • train_correlations (np.ndarray) – The train correlations between views.

  • test_correlations (np.ndarray) – The test correlations between views.

figure_

The figure of the plot.

Type:

matplotlib.pyplot.figure

Examples

>>> from cca_zoo.visualisation import CorrelationHeatmapDisplay
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from cca_zoo.linear import MCCA
>>>
>>> # 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:]
>>>
>>> views = [X_train, Y_train]
>>> test_views = [X_test, Y_test]
>>>
>>> # Train an MCCA Model
>>> # -------------------
>>> mcca = MCCA(latent_dimensions=2)
>>> mcca.fit(views)
>>>
>>> # %%
>>> # Plotting the Correlation Heatmap
>>> # -------------------------------
>>> CorrelationHeatmapDisplay.from_estimator(mcca, views, test_views=test_views).plot()
>>> plt.show()
class cca_zoo.visualisation.CovarianceHeatmapDisplay(train_covariances, test_covariances)[source]

Bases: object

Covariance Heatmap Display

Heatmap of the covariances between the latent variables of the views.

Parameters:
  • train_covariances (np.ndarray) – The train covariances between views.

  • test_covariances (np.ndarray) – The test covariances between views.

figure_

The figure of the plot.

Type:

matplotlib.pyplot.figure

Examples

>>> from cca_zoo.visualisation import CovarianceHeatmapDisplay
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from cca_zoo.linear import MCCA
>>>
>>> # 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:]
>>>
>>> views = [X_train, Y_train]
>>> test_views = [X_test, Y_test]
>>>
>>> # Train an MCCA Model
>>> # -------------------
>>> mcca = MCCA(latent_dimensions=2)
>>> mcca.fit(views)
>>>
>>> # %%
>>> # Plotting the Covariance Heatmap
>>> # -------------------------------
>>> CovarianceHeatmapDisplay.from_estimator(mcca, views, test_views=test_views).plot()
>>> plt.show()
class cca_zoo.visualisation.ExplainedCovarianceDisplay(explained_covariance_train, explained_covariance_test=None, ratio=True, **kwargs)[source]

Bases: object

Display the explained covariance of the latent variables of the views.

Parameters:
  • explained_covariance_train (np.ndarray) – The explained covariance of the train data.

  • explained_covariance_test (np.ndarray) – The explained covariance of the test data.

  • ratio (bool) – Whether to plot the ratio of explained covariance 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 ExplainedCovarianceDisplay
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from cca_zoo.linear import MCCA
>>>
>>> # 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:]
>>>
>>> views = [X_train, Y_train]
>>> test_views = [X_test, Y_test]
>>>
>>> # Train an MCCA Model
>>> # -------------------
>>> mcca = MCCA(latent_dimensions=2)
>>> mcca.fit(views)
>>>
>>> # %%
>>> # Plotting the Explained Covariance
>>> # ---------------------------------
>>> ExplainedCovarianceDisplay.from_estimator(mcca, views, test_views=test_views).plot()
>>> plt.show()
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 views.

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 MCCA
>>>
>>> # 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:]
>>>
>>> views = [X_train, Y_train]
>>> test_views = [X_test, Y_test]
>>>
>>> # Train an MCCA Model
>>> # -------------------
>>> mcca = MCCA(latent_dimensions=2)
>>> mcca.fit(views)
>>>
>>> # %%
>>> # Plotting the Explained Variance
>>> # ---------------------------------
>>> ExplainedVarianceDisplay.from_estimator(mcca, views, test_views=test_views).plot()
>>> plt.show()
class cca_zoo.visualisation.ScoreDisplay(train_scores, test_scores, labels=None, test_labels=None, **kwargs)[source]

Bases: object

Display the scores of a model

class cca_zoo.visualisation.WeightHeatmapDisplay(weights, view_labels=None, **kwargs)[source]

Bases: object

Heatmap of the weights of a model.

Parameters:

model (CCA model) – A fitted CCA model.

plot(**kwargs)[source]

Plot the heatmap.

Parameters:
  • ax (matplotlib axes, optional) – Axes to plot on, by default None.

  • kwargs (dict) – Keyword arguments to pass to seaborn.heatmap

Returns:

ax – Axes with the heatmap.

Return type:

matplotlib axes