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


Python hp.randint方法代码示例

本文整理汇总了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 
开发者ID:asreview,项目名称:asreview,代码行数:19,代码来源:doc2vec.py

示例2: options

# 需要导入模块: from hyperopt import hp [as 别名]
# 或者: from hyperopt.hp import randint [as 别名]
def options(self):
        return {
            'length': hp.randint('length', 1, 30, 1),
        } 
开发者ID:noda-sin,项目名称:ebisu,代码行数:6,代码来源:strategy.py

示例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 
开发者ID:asreview,项目名称:asreview,代码行数:11,代码来源:embedding_lstm.py

示例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 
开发者ID:asreview,项目名称:asreview,代码行数:10,代码来源:base.py

示例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 
开发者ID:doncat99,项目名称:StockRecommendSystem,代码行数:48,代码来源:Stock_Prediction_Run.py

示例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}") 
开发者ID:IBM,项目名称:lale,代码行数:46,代码来源:lale_hyperopt.py


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