本文整理汇总了Python中joblib.Parallel.reset_index方法的典型用法代码示例。如果您正苦于以下问题:Python Parallel.reset_index方法的具体用法?Python Parallel.reset_index怎么用?Python Parallel.reset_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类joblib.Parallel
的用法示例。
在下文中一共展示了Parallel.reset_index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_TADs
# 需要导入模块: from joblib import Parallel [as 别名]
# 或者: from joblib.Parallel import reset_index [as 别名]
def find_TADs(self, data, gammalist=range(10, 110, 10), segmentation='potts',
minlen=3, drop_gamma=False, n_jobs='auto'):
'''
Finds TADs in data with a list of gammas. Returns a pandas DataFrame
with columns 'Start', 'End' and 'Gamma'. Use genome_intervals_to_chr on
the returned object to get coordinates in bed-style format and not in
coordinates of concatenated genome.
If *drop_gamma*, drops the 'Gamma' column (useful when using 1 gamma)
'''
raise DeprecationWarning('Will be deprecated or rewritten to use'\
'lavaburst: github.com/nezar-compbio/lavaburst')
if n_jobs is 'auto': #Empirical values on my computer; with >8 Gb memory try increasing n_jobs
if segmentation == 'potts':
n_jobs = 3
elif segmentation == 'armatus':
n_jobs = 6
if ~np.isfinite(data).any():
print 'Non-finite values in data, substituting them with zeroes'
data[~np.isfinite(data)] = 0
Wcomm, Wnull, pass_mask, length = _precalculate_TADs_in_array(data)
f = _calculate_TADs
if n_jobs >= 1:
from joblib import Parallel, delayed
domains = Parallel(n_jobs=n_jobs, max_nbytes=1e6)(
delayed(f)(Wcomm, Wnull, pass_mask, length, g, segmentation)
for g in gammalist)
elif n_jobs is None or n_jobs == False or n_jobs == 0:
domains = []
for g in gammalist:
domains_g = f(Wcomm, Wnull, pass_mask, length, g, segmentation)
domains.append(domains_g)
domains = pd.concat(domains, ignore_index=True)
domains = domains.query('End-Start>='+str(minlen)).copy()
domains = domains.sort(columns=['Gamma', 'Start', 'End'])
domains.reset_index(drop=True, inplace=True)
domains[['Start', 'End']] = domains[['Start', 'End']].astype(int)
domains[['Start', 'End']] *= self.resolution
domains = domains[['Start', 'End', 'Score', 'Gamma']]
if drop_gamma:
domains.drop('Gamma', axis=1, inplace=True)
domains = self.genome_intervals_to_chr(domains).reset_index(drop=True)
return domains
示例2: retrieve_proposals
# 需要导入模块: from joblib import Parallel [as 别名]
# 或者: from joblib.Parallel import reset_index [as 别名]
def retrieve_proposals(video_info, model, feature_filename,
feat_size=16, stride_intersection=0.1):
"""Retrieve proposals for a given video.
Parameters
----------
video_info : DataFrame
DataFrame containing the 'video-name' and 'video-frames'.
model : dict
Dictionary containing the learned model.
Keys:
'D': 2darray containing the sparse dictionary.
'cost': Cost function at the last iteration.
'durations': 1darray containing typical durations (n-frames)
in the training set.
'type': Dictionary type.
feature_filename : str
String containing the path to the HDF5 file containing
the features for each video. The HDF5 file must contain
a group for each video where the id of the group is the name
of the video; and each group must contain a dataset containing
the features.
feat_size : int, optional
Size of the temporal extension of the features.
stride_intersection : float, optional
Percentage of intersection between temporal windows.
"""
feat_obj = FeatHelper(feature_filename, t_stride=1)
candidate_df = generate_candidate_proposals(video_info, model['durations'],
feat_size, stride_intersection)
D = model['D']
params = model['params']
feat_obj.open_instance()
feat_stack = feat_obj.read_feat(video_info['video-name'])
feat_obj.close_instance()
n_feats = feat_stack.shape[0]
candidate_df = candidate_df[
(candidate_df['f-init'] + candidate_df['n-frames']) <= n_feats]
candidate_df = candidate_df.reset_index(drop=True)
proposal_df = Parallel(n_jobs=-1)(delayed(wrapper_score_proposals)(this_df,
D,
feat_stack,
params,
feat_size)
for k, this_df in candidate_df.iterrows())
proposal_df = pd.concat(proposal_df, axis=1).T
proposal_df['score'] = (
proposal_df['score'] - proposal_df['score'].min()) / (
proposal_df['score'].max() - proposal_df['score'].min())
proposal_df['score'] = np.abs(proposal_df['score'] - 1.0)
proposal_df = proposal_df.loc[proposal_df['score'].argsort()[::-1]]
proposal_df = proposal_df.rename(columns={'n-frames': 'f-end'})
proposal_df['f-end'] = proposal_df['f-init'] + proposal_df['f-end'] - 1
return proposal_df.reset_index(drop=True)