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


Python Utils.get_seed方法代码示例

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


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

示例1: _objective

# 需要导入模块: from Utils import Utils [as 别名]
# 或者: from Utils.Utils import get_seed [as 别名]
    def _objective(self, classifier):
        self._iteration += 1

        if self._n_folds > 1:
            x = np.concatenate((self._x_test, self._x_train), axis=0)
            y = np.concatenate((self._y_test, self._y_train), axis=0)

            shuffle(x, y, random_state=Utils.get_seed())

            score_arr = cross_val_score(classifier, x, y, cv=self._n_folds, n_jobs=-1)
            score = np.mean(score_arr)
        else:
            classifier.fit(self._x_train, self._y_train)
            score = classifier.score(self._x_test, self._y_test)

        return -score
开发者ID:pawelpeksa,项目名称:feature_extraction_in_machine_learning,代码行数:18,代码来源:Optimizer.py

示例2: calculate

# 需要导入模块: from Utils import Utils [as 别名]
# 或者: from Utils.Utils import get_seed [as 别名]
def calculate(x_all, y_all):
    logging.warning('calculate')

    x_all, x_val, y_all, y_val = train_test_split(x_all, y_all, test_size=40, random_state=Utils.get_seed())

    # calculate for different train data size
    for train_data_size in Configuration.SAMPLES_N:
        logging.warning('calculate for data amount:{}'.format(train_data_size))

        if train_data_size < x_all.shape[0]:
            # get n_samples from dataset
            tmp, x, tmp, y = train_test_split(x_all, y_all, test_size=train_data_size, random_state=Utils.get_seed())
        else:
            x, y = x_all, y_all

        test_data_set(x, y, x_val, y_val)
开发者ID:pawelpeksa,项目名称:feature_extraction_in_machine_learning,代码行数:18,代码来源:main.py

示例3: test_given_extraction_method

# 需要导入模块: from Utils import Utils [as 别名]
# 或者: from Utils.Utils import get_seed [as 别名]
def test_given_extraction_method(x, y, x_val, y_val, reduction_object):
    logging.warning(
        "Testing extraction method:{0} for x shape:{1}".format(reduction_object.__class__.__name__, x.shape))

    svm_scores = list()
    ann_scores = list()
    decision_tree_scores = list()
    random_forest_scores = list()

    x, y, x_val, y_val = reduce_dimensions(x, y, x_val, y_val, reduction_object)

    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=Utils.get_seed())

    suffix = str(len(x))
    file_prefix = 'digits_' + suffix

    for i in range(1, 10):
        suffix = str(len(x))
        file_prefix = 'digits_' + suffix

        config = determine_parameters_all(x_train, y_train, x_test, y_test)

        logging.warning(
            'I:{0} \t Method:{1} Components_n:{2} result_file_prefix:{3}'.format(i, type(reduction_object).__name__,
                                                                                 reduction_object.n_components,
                                                                                 file_prefix))

        svm_score = fit_and_score_svm(x_train, y_train, x_val, y_val, config)
        ann_score = fit_and_score_ann(x_train, y_train, x_val, y_val, config)
        decision_tree_score = fit_and_score_decision_tree(x_train, y_train, x_val, y_val, config)
        random_forest_score = fit_and_score_random_forest(x_train, y_train, x_val, y_val, config)

        svm_scores.append(svm_score)
        ann_scores.append(ann_score)
        decision_tree_scores.append(decision_tree_score)
        random_forest_scores.append(random_forest_score)

    save_results(file_prefix, 'svm', reduction_object, svm_scores)
    save_results(file_prefix, 'ann', reduction_object, ann_scores)
    save_results(file_prefix, 'forest', reduction_object, random_forest_scores)
    save_results(file_prefix, 'tree', reduction_object, decision_tree_scores)
开发者ID:pawelpeksa,项目名称:feature_extraction_in_machine_learning,代码行数:43,代码来源:main.py


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