예제 #1
0
파일: schematic.py 프로젝트: andycasey/mcfa
#ax.set_yticks([])
fig.tight_layout()
#ax.set_frame_on(False)

# do left hand side table showing

J = 3
K = 4

D = 11
N = 25

X, true_theta = utils.generate_data(n_samples=N,
                                    n_features=D,
                                    n_components=K,
                                    n_latent_factors=J,
                                    omega_scale=0.1,
                                    noise_scale=0.1,
                                    random_seed=random_seed)

scores = true_theta["scores"]
tau = true_theta["R"]


def draw_matrix(ax,
                x,
                y,
                w,
                h,
                horizontal_grid_spacing=1,
                vertical_grid_spacing=1,
예제 #2
0
data_kwds = dict(n_features=n_features,
                 n_components=n_components,
                 n_latent_factors=n_latent_factors,
                 n_samples=n_samples,
                 omega_scale=omega_scale,
                 noise_scale=noise_scale,
                 random_seed=random_seed)

mcfa_kwds = dict(tol=1e-5,
                 max_iter=10000,
                 init_factors="random",
                 init_components="random",
                 random_seed=random_seed,
                 covariance_regularization=1e-6)

Y, truth = utils.generate_data(**data_kwds)
truth_packed = (truth["pi"], truth["A"], truth["xi"], truth["omega"],
                truth["psi"])

for missing_data_fraction in (0, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75,
                              0.9):

    # Throw away some data.
    missing_flat_indices = np.random.choice(Y.size,
                                            int(missing_data_fraction *
                                                Y.size),
                                            replace=False)
    is_missing = np.zeros(Y.size, dtype=bool)
    is_missing[missing_flat_indices] = True
    is_missing = is_missing.reshape(Y.shape)