本文整理汇总了Python中osprey.config.Config.fromdict方法的典型用法代码示例。如果您正苦于以下问题:Python Config.fromdict方法的具体用法?Python Config.fromdict怎么用?Python Config.fromdict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osprey.config.Config
的用法示例。
在下文中一共展示了Config.fromdict方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_estimator_entry_point
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_estimator_entry_point():
config = Config.fromdict({
'estimator': {
'entry_point': 'sklearn.cluster.KMeans',
}
}, check_fields=False)
assert isinstance(config.estimator(), KMeans)
示例2: test_search_engine_moe_2
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_search_engine_moe_2():
config = Config.fromdict({
'strategy': {'name': 'moe', 'params': {'url': 'abc'}}
}, check_fields=False)
strat = config.strategy()
assert isinstance(strat, MOE)
assert strat.url == 'abc'
示例3: test_search_space
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_search_space():
config = Config.fromdict({
'search_space': {
'intvar': {'type': 'int', 'min': 1, 'max': 2},
'logivar': {'type': 'int', 'min': 1, 'max': 2, 'warp': 'log'},
'fvar': {'type': 'float', 'min': 1, 'max': 3.5},
'logfvar': {'type': 'float', 'min': 1, 'max': 2.5, 'warp': 'log'},
'enumvar': {'type': 'enum', 'choices': [1, False]},
'jumpivar': {'type': 'jump', 'min': 1, 'max': 3, 'num': 3, 'var_type': int},
'jumpfvar': {'type': 'jump', 'min': 1, 'max': 3, 'num': 3, 'var_type': float},
'logjumpivar': {'type': 'jump', 'min': 10, 'max': 1000, 'num': 3, 'warp': 'log', 'var_type': int},
'logjumpfvar': {'type': 'jump', 'min': 10, 'max': 1000, 'num': 3, 'warp': 'log', 'var_type': float}
}}, check_fields=False)
searchspace = config.search_space()
assert searchspace['intvar'] == IntVariable('intvar', 1, 2, warp=None)
assert searchspace['logivar'] == IntVariable('logivar', 1, 2, warp='log')
assert searchspace['fvar'] == FloatVariable('fvar', 1, 3.5, warp=None)
assert searchspace['logfvar'] == FloatVariable('logfvar', 1, 2.5,
warp='log')
assert searchspace['enumvar'] == EnumVariable('enumvar', [1, False])
assert searchspace['jumpivar'] == EnumVariable('jumpivar', [1, 2, 3])
assert searchspace['jumpfvar'] == EnumVariable('jumpfvar', [1.0, 2.0, 3.0])
assert searchspace['logjumpivar'] == EnumVariable('logjumpivar', [10, 100, 1000])
assert searchspace['logjumpfvar'] == EnumVariable('logjumpfvar', [10.0, 100.0, 1000.0])
示例4: test_estimator_eval_2
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_estimator_eval_2():
config = Config.fromdict({
'estimator': {
'eval': 'KMeans()',
'eval_scope': ['sklearn'],
}
}, check_fields=False)
assert isinstance(config.estimator(), KMeans)
示例5: test_stratified_cv
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_stratified_cv():
from sklearn.cross_validation import StratifiedShuffleSplit
config = Config.fromdict({
'cv': {'name': 'stratifiedshufflesplit', 'params': {'n_iter': 10}}
}, check_fields=False)
cv = config.cv(range(100), np.random.randint(2, size=100))
assert isinstance(cv, StratifiedShuffleSplit)
assert cv.n_iter == 10
示例6: test_estimator_pickle
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_estimator_pickle():
with tempfile.NamedTemporaryFile('w+b', 0) as f:
cPickle.dump(KMeans(), f)
config = Config.fromdict({
'estimator': {'pickle': f.name}
}, check_fields=False)
assert isinstance(config.estimator(), KMeans)
示例7: test_cv_1
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_cv_1():
from sklearn.cross_validation import ShuffleSplit
for name in ['shufflesplit', 'ShuffleSplit']:
config = Config.fromdict({
'cv': {'name': name, 'params': {'n_iter': 10}}
}, check_fields=False)
cv = config.cv(range(100))
assert isinstance(cv, ShuffleSplit)
assert cv.n_iter == 10
示例8: test_estimator_entry_point_params
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_estimator_entry_point_params():
config = Config.fromdict({
'estimator': {
'entry_point': 'sklearn.cluster.KMeans',
'params': {
'n_clusters': 15
}
}
}, check_fields=False)
assert isinstance(config.estimator(), KMeans)
assert config.estimator().n_clusters == 15
示例9: test_search_space
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_search_space():
config = Config.fromdict({
'search_space': {
'intvar': {'type': 'int', 'min': 1, 'max': 2},
'fvar': {'type': 'float', 'min': 1, 'max': 3.5},
'logvar': {'type': 'float', 'min': 1, 'max': 2.5, 'warp': 'log'},
'enumvar': {'type': 'enum', 'choices': [1, False]},
}}, check_fields=False)
searchspace = config.search_space()
assert searchspace['intvar'] == IntVariable('intvar', 1, 2)
assert searchspace['fvar'] == FloatVariable('fvar', 1, 3.5, warp=None)
assert searchspace['logvar'] == FloatVariable('logvar', 1, 2.5, warp='log')
assert searchspace['enumvar'] == EnumVariable('enumvar', [1, False])
示例10: test_search_engine_moe_1
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_search_engine_moe_1():
config = Config.fromdict({
'strategy': {'name': 'moe', 'params': {'url': 'sdfsdf'}}
}, check_fields=False)
assert isinstance(config.strategy(), MOE)
示例11: test_search_engine_hyperopt_tpe
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_search_engine_hyperopt_tpe():
config = Config.fromdict({
'strategy': {'name': 'hyperopt_tpe'}
}, check_fields=False)
assert isinstance(config.strategy(), HyperoptTPE)
示例12: test_strategy_random
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_strategy_random():
config = Config.fromdict({
'strategy': {'name': 'random'}
}, check_fields=False)
assert isinstance(config.strategy(), RandomSearch)
示例13: test_scoring
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_scoring():
config = Config.fromdict({
'scoring': 'sdfsfsdf'
}, check_fields=False)
assert config.scoring() is 'sdfsfsdf'
示例14: test_random_seed
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_random_seed():
config = Config.fromdict({
'random_seed': 42
}, check_fields=False)
assert config.random_seed() == 42
示例15: test_search_engine_bayes
# 需要导入模块: from osprey.config import Config [as 别名]
# 或者: from osprey.config.Config import fromdict [as 别名]
def test_search_engine_bayes():
config = Config.fromdict({
'strategy': {'name': 'bayes'}
}, check_fields=False)
assert isinstance(config.strategy(), Bayes)