Skip to content

Commit

Permalink
Validation set for Gradient Based Models woohoo
Browse files Browse the repository at this point in the history
  • Loading branch information
jameschapman19 committed Oct 25, 2023
1 parent da9d02f commit 7e6ba2b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/source/examples/plot_dcca_custom_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# numpy arrays, each representing a distinct view, and an optional list of labels.
# Subsequently, these datasets can be converted into dataloaders for use in CCALoss-Zoo models.

from cca_zoo.data.utils import NumpyDataset
from cca_zoo.deep import DCCA, architectures
from cca_zoo.deep.utils import NumpyDataset

X = np.random.normal(size=(100, 10))
Y = np.random.normal(size=(100, 10))
Expand Down
8 changes: 4 additions & 4 deletions docs/source/examples/plot_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import matplotlib.pyplot as plt
import time

from cca_zoo.data.simulated import LinearSimulatedData
from cca_zoo.linear import CCA, CCA_EYLoss
from cca_zoo.datasets import JointData
from cca_zoo.linear import CCA, CCA_EY
from cca_zoo.visualisation import ScoreScatterDisplay

# %%
Expand All @@ -34,7 +34,7 @@
latent_dims = 1
correlation = 0.9

(X, Y) = LinearSimulatedData(
(X, Y) = JointData(
view_features=[p, q], latent_dims=latent_dims, correlation=[correlation]
).sample(n)

Expand Down Expand Up @@ -80,7 +80,7 @@

# We loop over the batch sizes and create a CCA_EYLoss object for each one
for batch_size in batch_sizes:
ccaey = CCA_EYLoss(
ccaey = CCA_EY(
latent_dimensions=latent_dims,
epochs=10,
batch_size=batch_size,
Expand Down
5 changes: 3 additions & 2 deletions docs/source/examples/plot_hyperparameter_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import numpy as np
import pandas as pd
from scipy.stats import loguniform
from cca_zoo.data.simulated import LinearSimulatedData

from cca_zoo.datasets import JointData
from cca_zoo.model_selection import GridSearchCV, RandomizedSearchCV
from cca_zoo.nonparametric import KCCA

Expand All @@ -34,7 +35,7 @@
latent_dims = 1
correlation = 0.9

data = LinearSimulatedData(
data = JointData(
view_features=[p, q], latent_dims=latent_dims, correlation=[correlation]
)
(X, Y) = data.sample(n)
Expand Down
5 changes: 3 additions & 2 deletions docs/source/examples/plot_kernel_cca.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# Dependencies
# ------------
import numpy as np
from cca_zoo.data.simulated import LinearSimulatedData

from cca_zoo.datasets import JointData
from cca_zoo.model_selection import GridSearchCV
from cca_zoo.nonparametric import KCCA

Expand All @@ -22,7 +23,7 @@

# Configuring and generating a simulated dataset with given specifications.
n, p, q, latent_dims, correlation = 200, 100, 100, 1, 0.9
(X, Y) = LinearSimulatedData(
(X, Y) = JointData(
view_features=[p, q], latent_dims=latent_dims, correlation=[correlation]
).sample(n)

Expand Down
5 changes: 3 additions & 2 deletions docs/source/examples/plot_many_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# Dependencies
# ------------
import numpy as np
from cca_zoo.data.simulated import LinearSimulatedData

from cca_zoo.datasets import JointData
from cca_zoo.linear import GCCA, MCCA, SCCA_PMD, TCCA
from cca_zoo.nonparametric import KCCA, KGCCA, KTCCA

Expand All @@ -23,7 +24,7 @@
np.random.seed(42)
n, p, q, r, latent_dims, cv = 30, 3, 3, 3, 1, 3

(X, Y, Z) = LinearSimulatedData(
(X, Y, Z) = JointData(
view_features=[p, q, r], latent_dims=latent_dims, correlation=[0.9]
).sample(n)

Expand Down
5 changes: 3 additions & 2 deletions docs/source/examples/plot_sparse_cca.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split

from cca_zoo.datasets import JointData
from cca_zoo.linear import (
CCA,
PLS,
Expand All @@ -20,7 +22,6 @@
ElasticCCA,
SCCA_Span,
)
from cca_zoo.data.simulated import LinearSimulatedData
from cca_zoo.model_selection import GridSearchCV

# Plotting Configuration
Expand Down Expand Up @@ -88,7 +89,7 @@ def plot_model_weights(wx, wy, tx, ty, title="", save_path=None):
n, p, q = 500, 200, 200
latent_dims = 1
view_1_sparsity, view_2_sparsity = 0.1, 0.1
data = LinearSimulatedData(
data = JointData(
view_features=[p, q],
latent_dims=latent_dims,
view_sparsity=[view_1_sparsity, view_2_sparsity],
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/plot_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import matplotlib.pyplot as plt
from sklearn.model_selection import ShuffleSplit, KFold

from cca_zoo.data import JointDataGenerator
from cca_zoo.datasets import JointData
from cca_zoo.linear import CCA
from cca_zoo.model_selection import learning_curve, permutation_test_score

Expand Down Expand Up @@ -174,7 +174,7 @@ def plot_learning_curve(


# Data generation
(X, Y) = JointDataGenerator(
(X, Y) = JointData(
view_features=[p, q], latent_dims=latent_dims, correlation=correlations
).sample(n)

Expand Down

0 comments on commit 7e6ba2b

Please sign in to comment.