def _update_light_curve_data_for_next_epoch( light_curve_data: DataBase, next_day_data: DataBase, canonical_data: DataBase, is_queryable: bool, strategy: str, is_separate_files: bool) -> DataBase: """ Updates samples for next epoch Parameters ---------- light_curve_data light curve learning data next_day_data next day light curve data canonical_data canonical strategy light curve data is_queryable If True, allow queries only on objects flagged as queryable. Default is True. strategy Query strategy. Options are (all can be run with budget): "UncSampling", "UncSamplingEntropy", "UncSamplingLeastConfident", "UncSamplingMargin", "QBDMI", "QBDEntropy", "RandomSampling", is_separate_files If True, consider samples separately read from independent files. Default is False. """ light_curve_data.pool_metadata = next_day_data.pool_metadata light_curve_data.pool_features = next_day_data.pool_features light_curve_data.pool_labels = next_day_data.pool_labels if not is_separate_files: light_curve_data.test_metadata = next_day_data.test_metadata light_curve_data.test_features = next_day_data.test_features light_curve_data.test_labels = next_day_data.test_labels light_curve_data.validation_metadata = next_day_data.validation_metadata light_curve_data.validation_features = next_day_data.validation_features light_curve_data.validation_labels = next_day_data.validation_labels if strategy == 'canonical': light_curve_data.queryable_ids = canonical_data.queryable_ids if is_queryable: queryable_flag = light_curve_data.pool_metadata['queryable'].values light_curve_data.queryable_ids = light_curve_data.pool_metadata[ 'id'].values[queryable_flag] else: light_curve_data.queryable_ids = light_curve_data.pool_metadata[ 'id'].values return light_curve_data
def _update_light_curve_data_val_and_test_data( light_curve_data: DataBase, first_loop_data: DataBase, is_separate_files: bool = False, initial_training: Union[str, int] = 'original', is_queryable: bool = False, number_of_classes: int = 2) -> DataBase: """ Updates initial light curve validation and test data Parameters ---------- light_curve_data initial light curve training data first_loop_data first loop light curve data is_queryable If True, allow queries only on objects flagged as queryable. Default is True. is_separate_files If True, consider samples separately read from independent files. Default is False. initial_training Choice of initial training sample. If 'original': begin from the train sample flagged in the file eilf 'previous': read training and queried from previous run. If int: choose the required number of samples at random, ensuring that at least half are SN Ia Default is 'original'. number_of_classes Number of classes to consider in the classification Currently only number_of_classes == 2 is implemented. """ if is_separate_files: light_curve_data.build_samples( nclass=number_of_classes, queryable=is_queryable, sep_files=is_separate_files, initial_training=initial_training) else: light_curve_data.test_features = first_loop_data.pool_features light_curve_data.test_metadata = first_loop_data.pool_metadata light_curve_data.test_labels = first_loop_data.pool_labels light_curve_data.validation_features = first_loop_data.pool_features light_curve_data.validation_metadata = first_loop_data.pool_metadata light_curve_data.validation_labels = first_loop_data.pool_labels return light_curve_data
def _update_next_day_val_and_test_data( next_day_data: DataBase, metadata_value: int, id_key_name: str) -> DataBase: """ Removes metadata value data from next day validation and test samples Parameters ---------- next_day_data next day light curve data metadata_value metadata object value id_key_name object identification key name """ if (len(next_day_data.validation_metadata) > 0 and metadata_value in next_day_data.validation_metadata[id_key_name].values): val_indices = list(next_day_data.validation_metadata[ id_key_name].values).index(metadata_value) next_day_data.validation_metadata = ( next_day_data.validation_metadata.drop( next_day_data.validation_metadata.index[val_indices])) next_day_data.validation_labels = np.delete( next_day_data.validation_labels, val_indices, axis=0) next_day_data.validation_features = np.delete( next_day_data.validation_features, val_indices, axis=0) if (len(next_day_data.test_metadata) > 0 and metadata_value in next_day_data.test_metadata[id_key_name].values): test_indices = list(next_day_data.test_metadata[ id_key_name].values).index(metadata_value) next_day_data.test_metadata = ( next_day_data.test_metadata.drop( next_day_data.test_metadata.index[test_indices])) next_day_data.test_labels = np.delete( next_day_data.test_labels, test_indices, axis=0) next_day_data.test_features = np.delete( next_day_data.test_features, test_indices, axis=0) return next_day_data