@@ -705,117 +705,6 @@ def replica_mask(exps_masks, replica, experiments_index, diagonal_basis=True):
705705 return df_tr , df_vl
706706
707707
708- def replica_validation_mask (exps_tr_masks , replica , experiments_index , diagonal_basis = True ):
709- """Save the boolean mask used to split data into training and validation
710- for a given replica as a pandas DataFrame, indexed by
711- :py:func:`validphys.results.experiments_index`. Can be used to reconstruct
712- the training and validation data used in a fit.
713-
714- Parameters
715- ----------
716- exps_tr_masks: list[list[np.array]]
717- Result of :py:func:`tr_masks` collected over experiments, which creates
718- the nested structure. The outer list is
719- len(group_dataset_inputs_by_experiment) and the inner-most list has an
720- array for each dataset in that particular experiment - as defined by the
721- metadata. The arrays should be 1-D boolean arrays which can be used as
722- masks.
723- replica: int
724- The index of the replica.
725- experiments_index: pd.MultiIndex
726- Index returned by :py:func:`validphys.results.experiments_index`.
727-
728-
729- Example
730- -------
731- >>> from validphys.api import API
732- >>> ds_inp = [
733- ... {'dataset': 'NMC', 'frac': 0.75},
734- ... {'dataset': 'ATLASTTBARTOT', 'cfac':['QCD'], 'frac': 0.75},
735- ... {'dataset': 'CMSZDIFF12', 'cfac':('QCD', 'NRM'), 'sys':10, 'frac': 0.75}
736- ... ]
737- >>> API.replica_training_mask(dataset_inputs=ds_inp, replica=1, trvlseed=123, theoryid=162, use_cuts="nocuts", mcseed=None, genrep=False)
738- replica 1
739- group dataset id
740- NMC NMC 0 True
741- 1 True
742- 2 False
743- 3 True
744- 4 True
745- ... ...
746- CMS CMSZDIFF12 45 True
747- 46 True
748- 47 True
749- 48 False
750- 49 True
751-
752- [345 rows x 1 columns]
753- """
754-
755- all_masks = np .concatenate (
756- [ds_mask for exp_masks in exps_masks for ds_mask .vl_masks in exp_masks ]
757- )
758- if diagonal_basis :
759- return pd .DataFrame (
760- all_masks ,
761- columns = [f"replica { replica } " ],
762- index = [f"eigenmode { i } " for i in range (len (all_masks ))],
763- )
764- else :
765- return pd .DataFrame (all_masks , columns = [f"replica { replica } " ], index = experiments_index )
766-
767-
768- replicas_mask = collect ("replica_mask" , ("replicas" ,))
769-
770-
771- @table
772- def training_mask_table (training_mask ):
773- """Same as ``training_mask`` but with a table decorator"""
774- return training_mask
775-
776-
777- def training_mask (replicas_mask ):
778- """Save the boolean mask used to split data into training and validation
779- for each replica as a pandas DataFrame, indexed by
780- :py:func:`validphys.results.experiments_index`. Can be used to reconstruct
781- the training and validation data used in a fit.
782-
783- Parameters
784- ----------
785- replicas_exps_tr_masks: list[list[list[np.array]]]
786- Result of :py:func:`replica_tr_masks` collected over replicas
787-
788- Example
789- -------
790- >>> from validphys.api import API
791- >>> from reportengine.namespaces import NSList
792- >>> # create namespace list for collects over replicas.
793- >>> reps = NSList(list(range(1, 4)), nskey="replica")
794- >>> ds_inp = [
795- ... {'dataset': 'NMC_NC_NOTFIXED_P_EM-SIGMARED', 'variant': 'legacy', 'frac': 0.75},
796- ... {'dataset': 'ATLAS_TTBAR_7TEV_TOT_X-SEC', 'variant': 'legacy_theory', 'frac': 0.75},
797- ... {'dataset': 'CMS_Z0J_8TEV_PT-Y', 'cfac':('NRM',), 'frac': 0.75},
798- ... ]
799- >>> API.training_mask(dataset_inputs=ds_inp, nreplica=3, trvlseed=123, theoryid=40_000_000, use_cuts="nocuts", mcseed=None, genrep=False)
800- replica 1 replica 2 replica 3
801- group dataset id
802- NMC NMC_NC_NOTFIXED_P_EM-SIGMARED 0 True False False
803- 1 True True True
804- 2 True False True
805- 3 True True False
806- 4 False True True
807- ... ... ... ...
808- CMS CMS_Z0J_8TEV_PT-Y 45 True False True
809- 46 True True True
810- 47 True False True
811- 48 True True True
812- 49 True False True
813- [343 rows x 3 columns]
814-
815- """
816- return pd .concat (replicas_training_mask , axis = 1 )
817-
818-
819708def _fitting_lagrange_dict (lambdadataset ):
820709 """Loads a generic lambda dataset, often used for positivity and integrability datasets
821710 For more information see :py:func:`validphys.n3fit_data_utils.positivity_reader`.
0 commit comments