コード例 #1
0
ファイル: test_elastic.py プロジェクト: svaiter/sparse-ho
from sparse_ho.ho import grad_search
from sparse_ho.utils import Monitor
from scipy.sparse import csc_matrix

n_samples = 10
n_features = 20
n_active = 5
tol = 1e-16
max_iter = 50000
SNR = 3
rho = 0.1
X_train, y_train, beta_star, noise, sigma_star = get_synt_data(
    dictionary_type="Gaussian",
    n_samples=n_samples,
    n_features=n_features,
    n_times=1,
    n_active=n_active,
    rho=rho,
    SNR=SNR,
    seed=0)
X_train = csc_matrix(X_train)
X_test, y_test, beta_star, noise, sigma = get_synt_data(
    dictionary_type="Gaussian",
    n_samples=n_samples,
    n_features=n_features,
    n_times=1,
    n_active=n_active,
    rho=rho,
    SNR=SNR,
    seed=1)
X_test = csc_matrix(X_test)
コード例 #2
0
ファイル: test_lasso.py プロジェクト: QB3/sparse-ho-qbe
from sparse_ho import Forward
from sparse_ho import ImplicitForward
from sparse_ho import Implicit
from sparse_ho import Backward
from sparse_ho.criterion import HeldOutMSE, SmoothedSURE

n_samples = 100
n_features = 100
n_active = 5
SNR = 3
rho = 0.1

X, y, beta_star, noise, sigma_star = get_synt_data(dictionary_type="Toeplitz",
                                                   n_samples=n_samples,
                                                   n_features=n_features,
                                                   n_times=1,
                                                   n_active=n_active,
                                                   rho=rho,
                                                   SNR=SNR,
                                                   seed=0)
X_s = csc_matrix(X)

idx_train = np.arange(0, 50)
idx_val = np.arange(50, 100)

alpha_max = (np.abs(X[idx_train, :].T @ y[idx_train])).max() / n_samples
p_alpha = 0.9
alpha = p_alpha * alpha_max
log_alpha = np.log(alpha)

log_alphas = np.log(alpha_max * np.geomspace(1, 0.1))
tol = 1e-16