Пример #1
0
def toy_spline_kpl_corr2(kernel_sigma, regu, tasks_correl):
    # Spline dict
    locs_bounds = np.array(
        [toy_data_spline.FREQS[0], toy_data_spline.FREQS[-1]])
    freqs_bounds = toy_data_spline.FREQS[0], toy_data_spline.FREQS[-1]
    width = toy_data_spline.WIDTH
    domain = np.expand_dims(np.array(
        [freqs_bounds[0] - width / 2, freqs_bounds[1] + width / 2]),
                            axis=0)
    func_dict = basis.BSplineUniscaleBasis(domain,
                                           freqs_bounds[1],
                                           locs_bounds,
                                           width=width,
                                           add_constant=False)
    # Scalar kernel
    gauss_ker = kernels.GaussianScalarKernel(kernel_sigma, normalize=False)
    # Operator valued kernel matrix
    output_matrix_params = {"omega": tasks_correl}
    # output_matrices = configs_generation.subconfigs_combinations("chain_graph", output_matrix_params)
    output_matrices = configs_generation.subconfigs_combinations(
        "all_related", output_matrix_params)
    params = {
        "kernel": gauss_ker,
        "regu": regu,
        "B": output_matrices,
        "basis_out": func_dict,
        "center_output": False
    }
    configs = configs_generation.configs_combinations(params)
    # Create list of regressors from that config
    regs = [kproj_learning.SeperableKPL(**config) for config in configs]
    return configs, regs
Пример #2
0
def toy_spline_kpl2(kernel_sigma, regu):
    # Spline dict
    locs_bounds = np.array(
        [toy_data_spline.FREQS[0], toy_data_spline.FREQS[-1]])
    freqs_bounds = toy_data_spline.FREQS[0], toy_data_spline.FREQS[-1]
    width = toy_data_spline.WIDTH
    domain = np.expand_dims(np.array(
        [freqs_bounds[0] - width / 2, freqs_bounds[1] + width / 2]),
                            axis=0)
    func_dict = basis.BSplineUniscaleBasis(domain,
                                           freqs_bounds[1],
                                           locs_bounds,
                                           width=width,
                                           add_constant=False)
    # Scalar kernel
    gauss_ker = kernels.GaussianScalarKernel(kernel_sigma, normalize=False)
    # Operator valued kernel matrix
    B = np.eye(func_dict.n_basis)
    regs = [
        kproj_learning.SeperableKPL(r,
                                    gauss_ker,
                                    B,
                                    func_dict,
                                    center_output=False) for r in regu
    ]
    configs = configs_generation.configs_combinations({"regu": regu})
    return configs, regs
Пример #3
0
def toy_spline_kpl_corr(kernel_sigma, regu, tasks_correl):
    # Spline dict
    locs_bounds = np.array(
        [toy_data_spline.BOUNDS_FREQS[0], toy_data_spline.BOUNDS_FREQS[1]])
    domain = toy_data_spline.DOM_OUTPUT
    func_dict = basis.BSplineUniscaleBasis(domain,
                                           toy_data_spline.BOUNDS_FREQS[-1],
                                           locs_bounds,
                                           width=toy_data_spline.WIDTH,
                                           add_constant=False)
    # Scalar kernel
    gauss_ker = kernels.GaussianScalarKernel(kernel_sigma, normalize=False)
    # Operator valued kernel matrix
    output_matrix_params = {"omega": tasks_correl, "dim": func_dict.n_basis}
    # output_matrices = configs_generation.subconfigs_combinations("chain_graph", output_matrix_params)
    output_matrices = configs_generation.subconfigs_combinations(
        "neighbors_correl", output_matrix_params)
    params = {
        "kernel": gauss_ker,
        "regu": regu,
        "B": output_matrices,
        "basis_out": func_dict,
        "center_output": False
    }
    configs = configs_generation.configs_combinations(params)
    # Create list of regressors from that config
    regs = [kproj_learning.SeperableKPL(**config) for config in configs]
    return configs, regs
Пример #4
0
def dti_wavs_kpl(kernel_sigma,
                 regu,
                 center_output=True,
                 decrease_base=1,
                 pywt_name="db",
                 moments=2,
                 n_dilat=4,
                 init_dilat=1.0,
                 translat=1.0,
                 dilat=2,
                 approx_level=5,
                 add_constant=True,
                 domain=np.array([[0, 1]]),
                 locs_bounds=np.array([[0, 1]])):
    # Wavelets output basses
    output_basis_params = {
        "pywt_name": pywt_name,
        "moments": moments,
        "init_dilat": init_dilat,
        "translat": translat,
        "dilat": dilat,
        "n_dilat": n_dilat,
        "approx_level": approx_level,
        "add_constant": add_constant,
        "locs_bounds": locs_bounds,
        "domain": domain
    }
    output_bases = configs_generation.subconfigs_combinations(
        "wavelets",
        output_basis_params,
        exclude_list=["domain", "locs_bounds"])
    # Gaussian kernel
    kernel = kernels.GaussianScalarKernel(kernel_sigma, normalize=False)
    # Penalize power
    output_matrix_params = {"decrease_base": decrease_base}
    output_matrices = configs_generation.subconfigs_combinations(
        "wavelets_pow", output_matrix_params)
    # Generate full configs
    params = {
        "kernel": kernel,
        "B": output_matrices,
        "basis_out": output_bases,
        "regu": regu,
        "center_output": center_output
    }
    configs = configs_generation.configs_combinations(params)
    # Create list of regressors from that config
    regs = [kproj_learning.SeperableKPL(**config) for config in configs]
    return configs, regs
Пример #5
0
def speech_rffs_kpl(kernel_sigma,
                    regu,
                    n_rffs,
                    rffs_sigma,
                    seed_rffs,
                    center_output,
                    domain=np.array([[0, 1]])):
    # FPCA output basis
    output_basis_params = {
        "n_basis": n_rffs,
        "bandwidth": rffs_sigma,
        "input_dim": 1,
        "domain": domain,
        "seed": seed_rffs
    }
    output_bases = configs_generation.subconfigs_combinations(
        "random_fourier", output_basis_params, exclude_list=["domain"])
    # Sum of Gaussian kernels
    kernel_sigmas = kernel_sigma * np.ones(13)
    gauss_kers = [
        kernels.GaussianScalarKernel(sig, normalize=False, normalize_dist=True)
        for sig in kernel_sigmas
    ]
    multi_ker = kernels.SumOfScalarKernel(gauss_kers, normalize=False)
    # Penalize power
    output_matrix_params = {}
    output_matrices = configs_generation.subconfigs_combinations(
        "eye", output_matrix_params)
    # Generate full configs
    params = {
        "kernel": multi_ker,
        "B": output_matrices,
        "basis_out": output_bases,
        "regu": regu,
        "center_output": center_output
    }
    configs = configs_generation.configs_combinations(params)
    # Create list of regressors from that config
    regs = [kproj_learning.SeperableKPL(**config) for config in configs]
    return configs, regs
Пример #6
0
def speech_fpca_penpow_kpl(kernel_sigma,
                           regu,
                           n_fpca,
                           n_evals_fpca,
                           decrease_base,
                           domain=np.array([[0, 1]])):
    # FPCA output basis
    output_basis_params = {
        "n_basis": n_fpca,
        "input_dim": 1,
        "domain": domain,
        "n_evals": n_evals_fpca
    }
    output_bases = configs_generation.subconfigs_combinations(
        "functional_pca", output_basis_params, exclude_list=["domain"])
    # Sum of Gaussian kernels
    kernel_sigmas = kernel_sigma * np.ones(13)
    gauss_kers = [
        kernels.GaussianScalarKernel(sig, normalize=False, normalize_dist=True)
        for sig in kernel_sigmas
    ]
    multi_ker = kernels.SumOfScalarKernel(gauss_kers, normalize=False)
    # Penalize power
    output_matrix_params = {"decrease_base": decrease_base}
    output_matrices = configs_generation.subconfigs_combinations(
        "pow", output_matrix_params)
    # Generate full configs
    params = {
        "kernel": multi_ker,
        "B": output_matrices,
        "basis_out": output_bases,
        "regu": regu,
        "center_output": True
    }
    configs = configs_generation.configs_combinations(params)
    # Create list of regressors from that config
    regs = [kproj_learning.SeperableKPL(**config) for config in configs]
    return configs, regs
Пример #7
0
def toy_spline_kpl(kernel_sigma, regu):
    # Spline dict
    locs_bounds = np.array(
        [toy_data_spline.BOUNDS_FREQS[0], toy_data_spline.BOUNDS_FREQS[1]])
    domain = toy_data_spline.DOM_OUTPUT
    func_dict = basis.BSplineUniscaleBasis(domain,
                                           toy_data_spline.BOUNDS_FREQS[-1],
                                           locs_bounds,
                                           width=toy_data_spline.WIDTH,
                                           add_constant=False)
    # Scalar kernel
    gauss_ker = kernels.GaussianScalarKernel(kernel_sigma, normalize=False)
    # Operator valued kernel matrix
    B = np.eye(func_dict.n_basis)
    regs = [
        kproj_learning.SeperableKPL(r,
                                    gauss_ker,
                                    B,
                                    func_dict,
                                    center_output=False) for r in regu
    ]
    configs = configs_generation.configs_combinations({"regu": regu})
    return configs, regs