コード例 #1
0
def test_triweight():
    # -----------------------------------------------------------------------
    # test convenience class gives proper result
    triweight = Triweight()
    triweight_poly = Polynomial(shape=3)
    X = np.random.rand(10, 1)

    assert_array_equal(triweight(X), triweight_poly(X))
コード例 #2
0
def test_biweight():
    # -----------------------------------------------------------------------
    # test convenience class gives proper result
    biweight = Biweight()
    biweight_poly = Polynomial(shape=2)
    X = np.random.rand(10, 1)

    assert_array_equal(biweight(X), biweight_poly(X))
コード例 #3
0
def test_epanechnikov():
    # -----------------------------------------------------------------------
    # test convenience class gives proper result
    epanechnikov = Epanechnikov()
    epanechnikov_poly = Polynomial(shape=1)
    X = np.random.rand(10, 1)

    assert_array_equal(epanechnikov(X), epanechnikov_poly(X))
コード例 #4
0
def test_uniform():
    # -----------------------------------------------------------------------
    # test convenience class gives proper result
    uniform = Uniform()
    uniform_poly = Polynomial(shape=0)
    X = np.random.rand(10, 1)

    assert_array_equal(uniform(X), uniform_poly(X))
コード例 #5
0
    def param_grid(self):
        source_voxels = self.voxel_data.injection_mask.coordinates
        a, b = self.support_bounds(source_voxels, self.voxel_data.centroids)
        logging.debug("support_bounds: (%.0f, %.0f)", a, b)

        if self.search_support:
            supports = np.round(np.linspace(a, 2*b, 10))
        else:
            supports = [a]

        return dict(kernel=[Polynomial(shape=a, support=b)
                            for a, b in itertools.product(self.shapes, supports)])
コード例 #6
0
def fit_structure(cache,
                  structure_id,
                  experiments_exclude,
                  kernel_params,
                  model_option='standard'):
    data = ModelData(
        cache,
        structure_id).get_voxel_data(experiments_exclude=experiments_exclude)

    # nested cross val
    nw_kwargs = dict()
    if 'shape' in kernel_params:
        nw_kwargs['kernel'] = Polynomial(**kernel_params)
    else:
        nw_kwargs['kernel'] = 'rbf'
        nw_kwargs['gamma'] = kernel_params.pop('gamma')

    error = VoxelModelError(cache, data)
    return data, error.fit(**nw_kwargs, option=model_option)
コード例 #7
0
def test_polynomial():
    # -----------------------------------------------------------------------
    # test __init__
    polynomial = Polynomial()

    assert hasattr(polynomial, 'shape_bounds')