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


Python MemmapingPool.join方法代碼示例

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


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

示例1: get_score

# 需要導入模塊: from joblib.pool import MemmapingPool [as 別名]
# 或者: from joblib.pool.MemmapingPool import join [as 別名]
def get_score(data, labels, fold_pairs,
              name, model, param):
    """
    Function to get score for a classifier.

    Parameters
    ----------
    data: array-like
        Data from which to derive score.
    labels: array-like or list.
        Corresponding labels for each sample.
    fold_pairs: list of pairs of array-like
        A list of train/test indicies for each fold
        (Why can't we just use the KFold object?)
    name: string
        Name of classifier.
    model: WRITEME
    param: WRITEME
        Parameters for the classifier.
    """
    assert isinstance(name, str)
    logger.info("Classifying %s" % name)

    ksplit = len(fold_pairs)
    if name not in NAMES:
        raise ValueError("Classifier %s not supported. "
                         "Did you enter it properly?" % name)

    # Redefine the parameters to be used for RBF SVM (dependent on
    # training data)

    if True:  #better identifier here
        logger.info("Attempting to use grid search...")
        fScore = []
        for i, fold_pair in enumerate(fold_pairs):
            print ("Classifying a %s the %d-th out of %d folds..."
                   % (name, i+1, len(fold_pairs)))
            classifier = get_classifier(name, model, param, data[fold_pair[0], :])
            area = classify(data, labels, fold_pair, classifier)
            fScore.append(area)
    else:
        warnings.warn("Multiprocessing splits not tested yet.")
        pool = Pool(processes=min(ksplit, PROCESSORS))
        classify_func = lambda f : classify(
            data,
            labels,
            fold_pairs[f],
            classifier=get_classifier(
                name,
                model,
                param,
                data=data[fold_pairs[f][0], :]))
        fScore = pool.map(functools.partial(classify_func, xrange(ksplit)))
        pool.close()
        pool.join()

    return classifier, fScore
開發者ID:rdevon,項目名稱:polyssifier,代碼行數:59,代碼來源:polyssifier.py


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