ramjet.photometric_database.lightcurve_label_per_time_step_database¶
Code for representing a database of lightcurves for binary classification with a single label per time step.
Module Contents¶
-
class
LightcurveLabelPerTimeStepDatabase(data_directory='data')[source]¶ Bases:
ramjet.photometric_database.lightcurve_database.LightcurveDatabaseA representation of a database of lightcurves for binary classification with a single label per time step.
-
training_preprocessing(self, example_path_tensor: tf.Tensor)[source]¶ Loads and preprocesses the data for training.
Parameters: example_path_tensor – The tensor containing the path to the example to load. Returns: The example and its corresponding label.
-
evaluation_preprocessing(self, example_path_tensor: tf.Tensor)[source]¶ Loads and preprocesses the data for evaluation.
Parameters: example_path_tensor – The tensor containing the path to the example to load. Returns: The example and its corresponding label.
-
general_preprocessing(self, example_path_tensor: tf.Tensor)[source]¶ Loads and preprocesses the data.
Parameters: example_path_tensor – The tensor containing the path to the example to load. Returns: The example and its corresponding label.
-
make_uniform_length_requiring_positive(self, example: np.ndarray, label: np.ndarray, length: Union[int, None] = None, required_length_multiple_base: Union[int, None] = None, evaluation: bool = False)[source]¶ Extracts a random segment from an example of the length specified. For examples with a positive label, the segment is required to include at least 1 positive time step. Examples shorter than the specified length will be repeated to fit the length.
Parameters: - example – The example to extract a segment from.
- label – The label whose matching segment should be extracted.
- length – The length to make the example.
- required_length_multiple_base – An optional base which the length is rounded to.
- evaluation – Whether the script is evaluating (in which case we don’t want a random position).
Returns: The extracted segment and corresponding label.
-
static
valid_start_indexes_for_segment_including_positive(boolean_array: np.ndarray, segment_length: int)[source]¶ Gets all indexes of an array where a segment started at that index will include at least one True entry. In other words, an
Parameters: - boolean_array – The array indicating which positions are positive.
- segment_length – The length of the segments to consider.
Returns: The valid start indexes.
-
static
round_to_base(number: int, base: int)[source]¶ Rounds a number to a specific base/multiple.
Parameters: - number – The number to round.
- base – The base to round to.
Returns: The rounded number.
-
static
inference_postprocessing(label: Union[tf.Tensor, np.ndarray], prediction: Union[tf.Tensor, np.ndarray], length: int)[source]¶ Prepares the label and prediction for use alongside the original data. In particular, as the network may require a specific multiple size, the label and prediction may need to be slightly clipped or padded. Also ensures NumPy types for easy use.
Parameters: - label – The ground truth label (preprocessed for use by the network).
- prediction – The prediction from the network.
- length – The length of the original example before preprocessing.
Returns: The label and prediction prepared for comparison to the original unpreprocessed example.
-