Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing training mask tables #1423

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions validphys2/src/validphys/n3fit_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,12 @@ def validation_pseudodata(pseudodata_table, training_mask):


@table
def replica_training_mask_table(exps_tr_masks, replica, experiments_index):
def replica_training_mask_table(replica_training_mask):
"""Same as ``replica_training_mask`` but with a table decorator.
"""
return replica_training_mask

def replica_training_mask(exps_tr_masks, replica, experiments_index):
"""Save the boolean mask used to split data into training and validation
for a given replica as a pandas DataFrame, indexed by
:py:func:`validphys.results.experiments_index`. Can be used to reconstruct
Expand Down Expand Up @@ -435,7 +440,7 @@ def replica_training_mask_table(exps_tr_masks, replica, experiments_index):
... {'dataset': 'ATLASTTBARTOT', 'cfac':['QCD'], 'frac': 0.75},
... {'dataset': 'CMSZDIFF12', 'cfac':('QCD', 'NRM'), 'sys':10, 'frac': 0.75}
... ]
>>> API.replica_training_mask_table(dataset_inputs=ds_inp, replica=1, trvlseed=123, theoryid=162, use_cuts="nocuts", mcseed=None, genrep=False)
>>> API.replica_training_mask(dataset_inputs=ds_inp, replica=1, trvlseed=123, theoryid=162, use_cuts="nocuts", mcseed=None, genrep=False)
replica 1
group dataset id
NMC NMC 0 True
Expand Down Expand Up @@ -463,9 +468,15 @@ def replica_training_mask_table(exps_tr_masks, replica, experiments_index):
index=experiments_index
)

replicas_training_mask_table = collect("replica_training_mask_table", ("replicas",))
replicas_training_mask = collect("replica_training_mask", ("replicas",))

@table
def training_mask_table(replicas_training_mask_table):
def training_mask_table(training_mask):
"""Same as ``training_mask`` but with a table decorator
"""
return training_mask

def training_mask(replicas_training_mask):
"""Save the boolean mask used to split data into training and validation
for each replica as a pandas DataFrame, indexed by
:py:func:`validphys.results.experiments_index`. Can be used to reconstruct
Expand All @@ -487,7 +498,7 @@ def training_mask_table(replicas_training_mask_table):
... {'dataset': 'ATLASTTBARTOT', 'cfac':['QCD'], 'frac': 0.75},
... {'dataset': 'CMSZDIFF12', 'cfac':('QCD', 'NRM'), 'sys':10, 'frac': 0.75}
... ]
>>> API.training_mask_table(dataset_inputs=ds_inp, replicas=reps, trvlseed=123, theoryid=162, use_cuts="nocuts", mcseed=None, genrep=False)
>>> API.training_mask(dataset_inputs=ds_inp, replicas=reps, trvlseed=123, theoryid=162, use_cuts="nocuts", mcseed=None, genrep=False)
replica 1 replica 2 replica 3
group dataset id
NMC NMC 0 True False False
Expand All @@ -505,7 +516,7 @@ def training_mask_table(replicas_training_mask_table):
[345 rows x 3 columns]

"""
return pd.concat(replicas_training_mask_table, axis=1)
return pd.concat(replicas_training_mask, axis=1)


def fitting_pos_dict(posdataset):
Expand Down