当前位置: 首页>>代码示例>>Python>>正文


Python stats.randint方法代码示例

本文整理汇总了Python中scipy.stats.randint方法的典型用法代码示例。如果您正苦于以下问题:Python stats.randint方法的具体用法?Python stats.randint怎么用?Python stats.randint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.stats的用法示例。


在下文中一共展示了stats.randint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_w_prep_fit

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_w_prep_fit():
    """[Model Selection] Test run with preprocessing, single step."""
    evl = Evaluator(mape_scorer, cv=5, shuffle=False, random_state=100,
                    verbose=True)

    with open(os.devnull, 'w') as f, redirect_stdout(f):

        evl.fit(X, y,
                estimators=[OLS()],
                param_dicts={'ols': {'offset': randint(1, 10)}},
                preprocessing={'pr': [Scale()], 'no': []},
                n_iter=3)

    np.testing.assert_approx_equal(
            evl.results['test_score-m']['no.ols'],
            -24.903229451043195)

    np.testing.assert_approx_equal(
            evl.results['test_score-m']['pr.ols'],
            -26.510708862278072, 1)

    assert evl.results['params']['no.ols']['offset'] == 4
    assert evl.results['params']['pr.ols']['offset'] == 4 
开发者ID:flennerhag,项目名称:mlens,代码行数:25,代码来源:test_model_selection.py

示例2: erp_distance_measure_getter

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def erp_distance_measure_getter(X):
    """
    generate the erp distance measure
    :param X: dataset to derive parameter ranges from
    :return: distance measure and parameter range dictionary
    """
    stdp = dataset_properties.stdp(X)
    instance_length = dataset_properties.max_instance_length(
        X)  # todo should this use the max instance
    # length for unequal length dataset instances?
    max_raw_warping_window = np.floor((instance_length + 1) / 4)
    n_dimensions = 1  # todo use other dimensions
    return {
        'distance_measure': [cython_wrapper(erp_distance)],
        'dim_to_use': stats.randint(low=0, high=n_dimensions),
        'g': stats.uniform(0.2 * stdp, 0.8 * stdp - 0.2 * stdp),
        'band_size': stats.randint(low=0, high=max_raw_warping_window + 1)
        # scipy stats randint is exclusive on the max value, hence + 1
    } 
开发者ID:alan-turing-institute,项目名称:sktime,代码行数:21,代码来源:_proximity_forest.py

示例3: lcss_distance_measure_getter

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def lcss_distance_measure_getter(X):
    """
    generate the lcss distance measure
    :param X: dataset to derive parameter ranges from
    :return: distance measure and parameter range dictionary
    """
    stdp = dataset_properties.stdp(X)
    instance_length = dataset_properties.max_instance_length(
        X)  # todo should this use the max instance
    # length for unequal length dataset instances?
    max_raw_warping_window = np.floor((instance_length + 1) / 4)
    n_dimensions = 1  # todo use other dimensions
    return {
        'distance_measure': [cython_wrapper(lcss_distance)],
        'dim_to_use': stats.randint(low=0, high=n_dimensions),
        'epsilon': stats.uniform(0.2 * stdp, stdp - 0.2 * stdp),
        # scipy stats randint is exclusive on the max value, hence + 1
        'delta': stats.randint(low=0, high=max_raw_warping_window + 1)
    } 
开发者ID:alan-turing-institute,项目名称:sktime,代码行数:21,代码来源:_proximity_forest.py

示例4: test_params

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_params():
    """[Model Selection] Test raises on bad params."""
    evl = Evaluator(mape_scorer, verbose=2)

    np.testing.assert_raises(ValueError,
                             evl.fit, X, y,
                             estimators=[OLS()],
                             param_dicts={'bad.ols':
                                          {'offset': randint(1, 10)}},
                             preprocessing={'prep': [Scale()]}) 
开发者ID:flennerhag,项目名称:mlens,代码行数:12,代码来源:test_model_selection.py

示例5: test_raises

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_raises():
    """[Model Selection] Test raises on error."""

    evl = Evaluator(bad_scorer, verbose=1)

    with open(os.devnull, 'w') as f, redirect_stdout(f):
        np.testing.assert_raises(
            ValueError, evl.fit, X, y, estimators=[OLS()],
            param_dicts={'ols': {'offset': randint(1, 10)}}, n_iter=1) 
开发者ID:flennerhag,项目名称:mlens,代码行数:11,代码来源:test_model_selection.py

示例6: test_passes

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_passes():
    """[Model Selection] Test sets error score on failed scoring."""

    evl = Evaluator(bad_scorer, error_score=0, n_jobs=1, verbose=5)

    with open(os.devnull, 'w') as f, redirect_stdout(f):
        evl = np.testing.assert_warns(FitFailedWarning,
                                      evl.fit, X, y,
                                      estimators=[OLS()],
                                      param_dicts={'ols':
                                                   {'offset': randint(1, 10)}},
                                      n_iter=1)
    assert evl.results['test_score-m']['ols'] == 0 
开发者ID:flennerhag,项目名称:mlens,代码行数:15,代码来源:test_model_selection.py

示例7: test_no_prep

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_no_prep():
    """[Model Selection] Test run without preprocessing."""
    evl = Evaluator(mape_scorer, cv=5, shuffle=False,
                    random_state=100, verbose=12)

    with open(os.devnull, 'w') as f, redirect_stdout(f):
        evl.fit(X, y,
                estimators=[OLS()],
                param_dicts={'ols': {'offset': randint(1, 10)}},
                n_iter=3)

    np.testing.assert_approx_equal(
            evl.results['test_score-m']['ols'],
            -24.903229451043195)
    assert evl.results['params']['ols']['offset'] == 4 
开发者ID:flennerhag,项目名称:mlens,代码行数:17,代码来源:test_model_selection.py

示例8: test_w_prep_set_params

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_w_prep_set_params():
    """[Model Selection] Test run with preprocessing, sep param dists."""
    evl = Evaluator(mape_scorer, cv=5, shuffle=False, random_state=100,
                    verbose=2)

    params = {'no.ols': {'offset': randint(3, 6)},
              'pr.ols': {'offset': randint(1, 3)},
              }

    with open(os.devnull, 'w') as f, redirect_stdout(f):

        evl.fit(X, y,
                estimators={'pr': [OLS()], 'no': [OLS()]},
                param_dicts=params,
                preprocessing={'pr': [Scale()], 'no': []},
                n_iter=10)

    np.testing.assert_approx_equal(
            evl.results['test_score-m']['no.ols'],
            -18.684229451043198)

    np.testing.assert_approx_equal(
            evl.results['test_score-m']['pr.ols'],
            -7.2594502123869491)
    assert evl.results['params']['no.ols']['offset'] == 3
    assert evl.results['params']['pr.ols']['offset'] == 1 
开发者ID:flennerhag,项目名称:mlens,代码行数:28,代码来源:test_model_selection.py

示例9: test_rvs

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_rvs(self):
        vals = stats.randint.rvs(5,30,size=100)
        assert_(numpy.all(vals < 30) & numpy.all(vals >= 5))
        assert_(len(vals) == 100)
        vals = stats.randint.rvs(5,30,size=(2,50))
        assert_(numpy.shape(vals) == (2,50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.randint.rvs(15,46)
        assert_((val >= 15) & (val < 46))
        assert_(isinstance(val, numpy.ScalarType), msg=repr(type(val)))
        val = stats.randint(15,46).rvs(3)
        assert_(val.dtype.char in typecodes['AllInteger']) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:test_distributions.py

示例10: test_pdf

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_pdf(self):
        k = numpy.r_[0:36]
        out = numpy.where((k >= 5) & (k < 30), 1.0/(30-5), 0)
        vals = stats.randint.pmf(k,5,30)
        assert_array_almost_equal(vals,out) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_distributions.py

示例11: test_cdf

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_cdf(self):
        x = numpy.r_[0:36:100j]
        k = numpy.floor(x)
        out = numpy.select([k >= 30,k >= 5],[1.0,(k-5.0+1)/(30-5.0)],0)
        vals = stats.randint.cdf(x,5,30)
        assert_array_almost_equal(vals, out, decimal=12) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_distributions.py

示例12: parallel_params

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def parallel_params(log_dir, niter=10000, seed=123456789):
	"""
	Create the parameters for a parallel run.
	
	@param log_dir: The directory to store the results in.
	
	@param niter: The number of iterations to perform.
	
	@param seed: The seed for the random number generators.
	
	@return: Returns a tuple containing the parameters.
	"""
	
	static_params = {
		'ninputs': 784,
		'trim': 1e-4,
		'disable_boost': True,
		'seed': seed,
		'pct_active': None,
		'random_permanence': True,
		'pwindow': 0.5,		
		'global_inhibition': True,
		'syn_th': 0.5,
		'pinc': 0.001,
		'pdec': 0.001,		
		'nepochs': 10
	}
	dynamic_params = {
		'ncolumns': randint(500, 3500),
		'nactive': uniform(0.5, 0.35), # As a % of the number of columns
		'nsynapses': randint(25, 784),
		'seg_th': uniform(0, 0.2), # As a % of the number of synapses
		'log_dir': log_dir
	}
	
	# Build the parameter generator
	gen = ParamGenerator(dynamic_params, niter, 1, 784)
	params = {key:gen for key in dynamic_params}
	
	return static_params, params 
开发者ID:tehtechguy,项目名称:mHTM,代码行数:42,代码来源:mnist_novelty_detection.py

示例13: test_rvs

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_rvs(self):
        vals = stats.randint.rvs(5, 30, size=100)
        assert_(numpy.all(vals < 30) & numpy.all(vals >= 5))
        assert_(len(vals) == 100)
        vals = stats.randint.rvs(5, 30, size=(2, 50))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.randint.rvs(15, 46)
        assert_((val >= 15) & (val < 46))
        assert_(isinstance(val, numpy.ScalarType), msg=repr(type(val)))
        val = stats.randint(15, 46).rvs(3)
        assert_(val.dtype.char in typecodes['AllInteger']) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:14,代码来源:test_distributions.py

示例14: test_pdf

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_pdf(self):
        k = numpy.r_[0:36]
        out = numpy.where((k >= 5) & (k < 30), 1.0/(30-5), 0)
        vals = stats.randint.pmf(k, 5, 30)
        assert_array_almost_equal(vals, out) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:7,代码来源:test_distributions.py

示例15: test_cdf

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import randint [as 别名]
def test_cdf(self):
        x = numpy.r_[0:36:100j]
        k = numpy.floor(x)
        out = numpy.select([k >= 30, k >= 5], [1.0, (k-5.0+1)/(30-5.0)], 0)
        vals = stats.randint.cdf(x, 5, 30)
        assert_array_almost_equal(vals, out, decimal=12) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_distributions.py


注:本文中的scipy.stats.randint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。