當前位置: 首頁>>代碼示例>>Python>>正文


Python Job.params["seed"]方法代碼示例

本文整理匯總了Python中disco.core.Job.params["seed"]方法的典型用法代碼示例。如果您正苦於以下問題:Python Job.params["seed"]方法的具體用法?Python Job.params["seed"]怎麽用?Python Job.params["seed"]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在disco.core.Job的用法示例。


在下文中一共展示了Job.params["seed"]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fit

# 需要導入模塊: from disco.core import Job [as 別名]
# 或者: from disco.core.Job import params["seed"] [as 別名]
def fit(
    dataset,
    trees_per_chunk=3,
    max_tree_nodes=50,
    min_samples_leaf=10,
    min_samples_split=5,
    class_majority=1,
    measure="info_gain",
    k="sqrt",
    accuracy=1,
    random_state=None,
    separate_max=True,
    save_results=True,
    show=False,
):
    from disco.worker.pipeline.worker import Worker, Stage
    from disco.core import Job
    import discomll

    path = "/".join(discomll.__file__.split("/")[:-1] + ["ensemble", "core", ""])

    try:
        trees_per_chunk = int(trees_per_chunk)
        max_tree_nodes = int(max_tree_nodes) if max_tree_nodes != None else max_tree_nodes
        min_samples_leaf = int(min_samples_leaf)
        min_samples_split = int(min_samples_split)
        class_majority = float(class_majority)
        separate_max = separate_max
        accuracy = int(accuracy)

        if (
            trees_per_chunk <= 0
            or min_samples_leaf <= 0
            or min_samples_split <= 0
            or class_majority <= 0
            or accuracy < 0
        ):
            raise Exception("Parameters should be greater than 0.")
    except ValueError:
        raise Exception("Parameters should be numerical.")

    if measure not in ["info_gain", "mdl"]:
        raise Exception("measure should be set to info_gain or mdl.")

    job = Job(worker=Worker(save_results=save_results))
    job.pipeline = [
        ("split", Stage("map", input_chain=dataset.params["input_chain"], init=map_init, process=map_fit)),
        ("group_all", Stage("reduce", init=simple_init, process=reduce_fit, combine=True)),
    ]

    job.params = dataset.params
    job.params["trees_per_chunk"] = trees_per_chunk
    job.params["max_tree_nodes"] = max_tree_nodes
    job.params["min_samples_leaf"] = min_samples_leaf
    job.params["min_samples_split"] = min_samples_split
    job.params["class_majority"] = class_majority
    job.params["measure"] = measure
    job.params["accuracy"] = accuracy
    job.params["k"] = k
    job.params["seed"] = random_state
    job.params["separate_max"] = separate_max

    job.run(
        name="distributed_weighted_forest_fit",
        input=dataset.params["data_tag"],
        required_files=[path + "decision_tree.py", path + "measures.py", path + "k_medoids.py"],
    )

    fitmodel_url = job.wait(show=show)
    return {"dwf_fitmodel": fitmodel_url}  # return results url
開發者ID:romanorac,項目名稱:discomll,代碼行數:72,代碼來源:distributed_weighted_forest.py


注:本文中的disco.core.Job.params["seed"]方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。