Data
- class metamorphic_relations.Data.Data(train_x, train_y, test_x, test_y, max_y)[source]
Stores the data
- Parameters:
train_x (array) – a numpy array, the first dimension is the index of elements for training
train_y (array) – a 1D numpy array of label indices for training
test_x (array) – a numpy array, the first dimension is the index of elements for testing
test_y (array) – a 1D numpy array of label indices for testing
max_y (int) – the largest y value possible
- static concat_lists(lists)[source]
Takes a list of pairs of numpy arrays of xs and ys and makes them a single xs and ys list
- Parameters:
lists (list[tuple[numpy.array, numpy.array]]) – a numpy array of pairs of numpy arrays of xs and ys e.g. [[xs1, ys1], [xs2, ys2]]
- Returns:
a tuple of xs and ys e.g. (xs1 + xs2, ys1 + ys2)
- Return type:
tuple[numpy.array, numpy.array]
- get_train_subset(i_min=0, i_max=9999999)[source]
Gets a subset of the training data
- Parameters:
i_min (int) – the lower bound index (inclusive)
i_max (int) – the upper bound index (not inclusive)
- Returns:
train_x_subset, train_y_subset
- Return type:
tuple[numpy.array, numpy.array]
- static group_by_label(y, max_y)[source]
Groups an array of ints by their values. E.g. ([3, 3, 2, 3, 1, 0], 5) -> [[5], [4], [2], [0, 1, 3], []]
- Parameters:
y (array) – a numpy array of ints
max_y (int) – the maximum possible number of values
- Returns:
a list of y indices for each possible y value
- Return type:
list[list[int]]
- class metamorphic_relations.Results.Results(original_results=None, GMR_results=None, DSMR_results=None, all_MR_results=None, individual_results=None)[source]
Create an object to store and manipulate the results given multiple sets of metamorphic relations (MRs)
- Parameters:
original_results (Info) – the results using the original data
GMR_results (Info) – the results when augmenting the data with generic MRs (GMRs)
DSMR_results (Info) – the results when augmenting the data with domain specific MRs (DSMRs)
all_MR_results (Info) – the results when augmenting the data with GMRs and DSMRs
individual_results (list[Info]) – a list of results from individual MRs
- get_forall_sets(is_set=(True, True, True, True), get_set_function=None)[source]
For all sets of results which are not None call a function
- Parameters:
is_set (tuple[bool, bool, bool, bool]) – the sets of results to use of [“original_results”, “GMR_results”, “DSMR_results”, “all_MR_results”]. E.g. [True, False, True, False] uses [“original_results”, “DSMR_results”]
get_set_function (function) – the function to be used with the result sets
- Returns:
the results of the function for each non None set
- Return type:
list
- graph(set_name='', train_f1s=False, test_f1s=True, original_counts=True, show_sets=(True, True, True, True))[source]
Graphs the results of the deep learning with MRs
- Parameters:
set_name (str) – the name of the set trained, to be used in the title
train_f1s (bool) – choose whether to show the train F1 scores
test_f1s (bool) – choose whether to show the test F1 scores
original_counts (bool) – choose whether to show the F1 scores against the number of original training elements or the actual counts (number of training elements after the MRs)
show_sets (tuple[bool, bool, bool, bool]) – the sets of results to show of [“original_results”, “GMR_results”, “DSMR_results”, “all_MR_results”]. E.g. [True, False, True, False] shows [“original_results”, “DSMR_results”]
- graph_all(set_name='')[source]
Graphs the train and test results using original and actual counts
- Parameters:
set_name (str) – the name of the set trained, to be used in all the graph titles
- class metamorphic_relations.Info.Info(original_count, actual_count, train_f1, test_f1, name=None)[source]
Create an object to store and manipulate the information for a given set of metamorphic relations (MRs)
- Parameters:
original_count (list[int]) – the number of training elements before the MRs were used
actual_count (list[int]) – the number of training elements used in training (i.e. after the MRs were used)
train_f1 (list[float]) – the average F1 score over the training folds
test_f1 (list[float]) – the F1 score calculated on the test set
name (str) – the name of the info stored
- static from_JSON(string)[source]
Turns a JSON to an Info object
- Parameters:
string (str) – a string in JSON form with keys: “actual_count”, “original_count”, “train_f1”, “test_f1”, “name”
- Returns:
an Info object
- Return type: