本文整理汇总了Python中hyperopt.hp.randint方法的典型用法代码示例。如果您正苦于以下问题:Python hp.randint方法的具体用法?Python hp.randint怎么用?Python hp.randint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyperopt.hp
的用法示例。
在下文中一共展示了hp.randint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: full_hyper_space
# 需要导入模块: from hyperopt import hp [as 别名]
# 或者: from hyperopt.hp import randint [as 别名]
def full_hyper_space(self):
from hyperopt import hp
eps = 1e-7
hyper_space, hyper_choices = super(Doc2Vec, self).full_hyper_space()
hyper_space.update({
"fex_vector_size": hp.quniform(
"fex_vector_size", 31.5, 127.5-eps, 8),
"fex_epochs": hp.quniform("fex_epochs", 20, 50, 1),
"fex_min_count": hp.quniform("fex_min_count", 0.5, 2.499999, 1),
"fex_window": hp.quniform("fex_window", 4.5, 9.4999999, 1),
"fex_dm_concat": hp.randint("fex_dm_concat", 2),
"fex_dm": hp.randint("fex_dm", 3),
"fex_dbow_words": hp.randint("fex_dbow_words", 2),
})
return hyper_space, hyper_choices
示例2: options
# 需要导入模块: from hyperopt import hp [as 别名]
# 或者: from hyperopt.hp import randint [as 别名]
def options(self):
return {
'length': hp.randint('length', 1, 30, 1),
}
示例3: full_hyper_space
# 需要导入模块: from hyperopt import hp [as 别名]
# 或者: from hyperopt.hp import randint [as 别名]
def full_hyper_space(self):
from hyperopt import hp
hyper_space, hyper_choices = super(
EmbeddingLSTM, self).full_hyper_space()
hyper_space.update({
"fex_loop_sequences": hp.randint("fex_loop_sequences", 2)
})
return hyper_space, hyper_choices
示例4: full_hyper_space
# 需要导入模块: from hyperopt import hp [as 别名]
# 或者: from hyperopt.hp import randint [as 别名]
def full_hyper_space(self):
from hyperopt import hp
hyper_choices = {}
hyper_space = {
"fex_split_ta": hp.randint("fex_split_ta", 2),
"fex_use_keywords": hp.randint("fex_use_keywords", 2),
}
return hyper_space, hyper_choices
示例5: run_xgboost_classification
# 需要导入模块: from hyperopt import hp [as 别名]
# 或者: from hyperopt.hp import randint [as 别名]
def run_xgboost_classification(root_path, need_training, need_plot_training_diagram, need_predict):
df = getStocksList_CHN(root_path)
df.index = df.index.astype(str).str.zfill(6)
df = df.sort_index(ascending = True)
predict_symbols = df.index.values.tolist()
paras = SP_Paras('xgboost', root_path, predict_symbols, predict_symbols)
paras.save = True
paras.load = False
paras.run_hyperopt = True
paras.plot = need_plot_training_diagram
# A_B_C format:
# A: require window split or not -> 0 for not, 1 for yes
# B: normalization method -> 0: none 1: standard 2: minmax 3: zscore
# C: normalization index, same normalization requires different index
paras.features = {#'0_0_0':['week_day'],
#'1_0_1':['c_2_o', 'h_2_o', 'l_2_o', 'c_2_h', 'h_2_l', 'vol_p'],
'1_1_0':['buy_amount', 'sell_amount', 'even_amount'],
'1_1_1':['buy_volume', 'sell_volume', 'even_volume'],
'1_1_2':['buy_max', 'buy_min', 'buy_average', 'sell_max', 'sell_min', 'sell_average', 'even_max', 'even_min', 'even_average']}
paras.window_len = [3]
paras.pred_len = 1
paras.valid_len = 20
paras.start_date = '2016-11-01'
paras.end_date = datetime.datetime.now().strftime("%Y-%m-%d")
paras.verbose = 1
paras.batch_size = 64
paras.epoch = 10
paras.out_class_type = 'classification'
paras.n_out_class = 7 # ignore for regression
from hyperopt import hp
paras.hyper_opt = {"max_depth" :hp.randint("max_depth", 10),
"n_estimators" :hp.randint("n_estimators", 20), #[0,1,2,3,4,5] -> [50,]
"gamma" :hp.randint("gamma", 4), #0-0.4
"learning_rate" :hp.randint("learning_rate", 6), #[0,1,2,3,4,5] -> 0.05,0.06
"subsample" :hp.randint("subsample", 4), #[0,1,2,3] -> [0.7,0.8,0.9,1.0]
"min_child_weight" :hp.randint("min_child_weight", 5),
}
# run
xgboost_cla = xgboost_classification(paras)
xgboost_cla.run(need_training, need_predict)
return paras
示例6: visitSearchSpaceNumber
# 需要导入模块: from hyperopt import hp [as 别名]
# 或者: from hyperopt.hp import randint [as 别名]
def visitSearchSpaceNumber(self, space:SearchSpaceNumber, path:str, counter=None):
label = self.mk_label(path, counter)
if space.pgo is not None:
return scope.pgo_sample(space.pgo, hp.quniform(label, 0, len(space.pgo)-1, 1))
dist = "uniform"
if space.distribution:
dist = space.distribution
if space.maximum is None:
raise SearchSpaceError(path, f"maximum not specified for a number with distribution {dist}")
max = space.getInclusiveMax()
# These distributions need only a maximum
if dist == "integer":
if not space.discrete:
raise SearchSpaceError(path, "integer distribution specified for a non discrete numeric type")
return hp.randint(label, max)
if space.minimum is None:
raise SearchSpaceError(path, f"minimum not specified for a number with distribution {dist}")
min = space.getInclusiveMin()
if dist == "uniform":
if space.discrete:
return scope.int(hp.quniform(label, min, max, 1))
else:
return hp.uniform(label, min, max)
elif dist == "loguniform":
# for log distributions, hyperopt requires that we provide the log of the min/max
if min <= 0:
raise SearchSpaceError(path, f"minimum of 0 specified with a {dist} distribution. This is not allowed; please set it (possibly using minimumForOptimizer) to be positive")
if min > 0:
min = math.log(min)
if max > 0:
max = math.log(max)
if space.discrete:
return scope.int(hp.qloguniform(label, min, max, 1))
else:
return hp.loguniform(label, min, max)
else:
raise SearchSpaceError(path, f"Unknown distribution type: {dist}")