本文整理汇总了Python中joblib.pool.MemmapingPool.close方法的典型用法代码示例。如果您正苦于以下问题:Python MemmapingPool.close方法的具体用法?Python MemmapingPool.close怎么用?Python MemmapingPool.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类joblib.pool.MemmapingPool
的用法示例。
在下文中一共展示了MemmapingPool.close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_score
# 需要导入模块: from joblib.pool import MemmapingPool [as 别名]
# 或者: from joblib.pool.MemmapingPool import close [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