懷疑hash值不對是多進程環境下造成的

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : qichun tang
# @Contact    : [email protected]
import hashlib
import multiprocessing
def calc_hash():
    data=b'{\'estimating(choice)\': {\'lightgbm\': {\'_n_estimators-lr_ratio\': {\'_default\': 10, \'_type\': \'loguniform\', \'_value\': [0.1, 100]}, \'bagging_fraction\': {\'_default\': 1, \'_type\': \'quniform\', \'_value\': [0.05, 0.5, 1]}, \'boosting_type\': {\'_default\': \'gbdt\', \'_type\': \'choice\', \'_value\': [\'dart\', \'gbdt\', \'goss\']}, \'early_stopping_rounds\': 500, \'feature_fraction\': {\'_default\': 1, \'_type\': \'quniform\', \'_value\': [0.05, 0.5, 1]}, \'lambda_l1\': {\'_default\': 0, \'_type\': \'loguniform\', \'_value\': [10, 1e-07]}, \'lambda_l2\': {\'_default\': 0, \'_type\': \'loguniform\', \'_value\': [10, 1e-07]}, \'learning_rate\': {\'_default\': 0.1, \'_type\': \'loguniform\', \'_value\': [0.001, 0.2]}, \'max_depth\': {\'_default\': 31, \'_type\': \'int_quniform\', \'_value\': [1, 100]}, \'min_child_weight\': {\'_default\': 0.001, \'_type\': \'loguniform\', \'_value\': [10, 1e-07]}, \'min_data_in_leaf\': {\'_default\': 1, \'_type\': \'int_quniform\', \'_value\': [0, 1, 6]}, \'n_jobs\': 1, \'num_leaves\': {\'_default\': 31, \'_type\': \'int_quniform\', \'_value\': [10, 150]}, \'random_state\': 42, \'subsample_for_bin\': {\'_default\': 200000.0, \'_type\': \'int_quniform\', \'_value\': [20000.0, 20000.0, 300000.0]}}}, \'preprocessing\': {\'00highR_nan->nan(choice)\': {\'operate.drop\': {}, \'operate.merge\': {}}, \'01nan->imputed(choice)\': {\'impute.adaptive_fill\': {\'cat_strategy\': \'most_frequent\', \'num_strategy\': {\'_default\': \'median\', \'_type\': \'choice\', \'_value\': [\'mean\', \'median\']}}}, \'02imputed->cat,num(choice)\': {\'operate.split\': {\'column2fg\': "{\'Age\': \'num\', \'Fare\': \'num\', \'Cabin\': \'cat\', \'Embarked\': \'cat\'}:dict"}}, \'03cat->purified(choice)\': {\'encode.cat_boost\': {}, \'encode.one_hot\': {}, \'encode.ordinal\': {}}, \'04highR_cat->purified(choice)\': {\'encode.cat_boost\': {}, \'encode.ordinal\': {}, \'operate.drop\': {}}, \'05text->tokenized(choice)\': {\'text.tokenize.simple\': {}}, \'06tokenized->purified(choice)\': {\'text.topic.lsi\': {\'num_topics\': {\'_default\': 20, \'_type\': \'int_quniform\', \'_value\': [10, 10, 400]}}, \'text.topic.nmf\': {\'num_topics\': {\'_default\': 20, \'_type\': \'int_quniform\', \'_value\': [10, 10, 400]}, \'random_state\': 42}, \'text.topic.tsvd\': {\'num_topics\': {\'_default\': 10, \'_type\': \'int_quniform\', \'_value\': [200, 5, 5]}, \'random_state\': 42}}, \'07num->scaled(choice)\': {\'operate.merge\': {}, \'scale.standardize\': {\'copy\': False}}, \'08scaled->purified(choice)\': {\'operate.merge\': {}, \'transform.power\': {}}, \'09purified->final(choice)\': {\'operate.merge\': {}}}}'
    single_process_hash=hashlib.md5()
    single_process_hash.update(data)
    print(single_process_hash.hexdigest())

calc_hash()
processes=[]
for i in range(3):
    p = multiprocessing.Process(
        target=calc_hash,
        args=()
    )
    processes.append(p)
    p.start()
for p in processes:
    p.join()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章