Load ground truth lables if they exist Parameters: - filename -- Path to labels file Returns: - numpy array with labels to compare with the predicted similarity or None if no ground truth lables are provided
(filename)
| 144 | return [np_ds1, np_ds2] |
| 145 | |
| 146 | def loadLabels(filename): |
| 147 | """ |
| 148 | Load ground truth lables if they exist |
| 149 | Parameters: |
| 150 | - filename -- Path to labels file |
| 151 | Returns: |
| 152 | - numpy array with labels to compare with the predicted similarity |
| 153 | or None if no ground truth lables are provided |
| 154 | """ |
| 155 | if filename is None: |
| 156 | print("Labels of test samples are not specified") |
| 157 | print("Accuracy of DNN on this test cannot be evaluated") |
| 158 | return None |
| 159 | if not os.path.exists(filename): |
| 160 | print(f"File {filename} with labels of test samples is not found") |
| 161 | print("Accuracy of DNN on this test cannot be evaluated") |
| 162 | return None |
| 163 | labels = [] |
| 164 | with open(filename, newline='') as csvfile: |
| 165 | test_reader = csv.reader(csvfile) |
| 166 | test_reader.__next__() #Skip csv header |
| 167 | for _num, _lbl in test_reader: |
| 168 | labels.append(int(_lbl)) |
| 169 | return np.asarray(labels) |
| 170 | |
| 171 | def writePredictions(test, probabilities, filename): |
| 172 | """ |