MCPcopy Create free account
hub / github.com/Gabesarch/ICAL / plot_precision_recall

Function plot_precision_recall

TEACh/utils/plot_utils.py:223–254  ·  view source on GitHub ↗
(files, naming_scheme='iter')

Source from the content-addressed store, hash-verified

221
222
223def plot_precision_recall(files, naming_scheme='iter'):
224 if naming_scheme == 'exp_id':
225 # name becomes exp_id
226 names = [f.parts[-3] for f in files]
227 elif naming_scheme == 'iter':
228 names = [f.stem for f in files]
229 else:
230 raise ValueError(f'not supported {naming_scheme}')
231 fig, axs = plt.subplots(ncols=2, figsize=(16, 5))
232 for f, color, name in zip(files, sns.color_palette("Blues", n_colors=len(files)), names):
233 data = torch.load(f)
234 # precision is n_iou, n_points, n_cat, n_area, max_det
235 precision = data['precision']
236 recall = data['params'].recThrs
237 scores = data['scores']
238 # take precision for all classes, all areas and 100 detections
239 precision = precision[0, :, :, 0, -1].mean(1)
240 scores = scores[0, :, :, 0, -1].mean(1)
241 prec = precision.mean()
242 rec = data['recall'][0, :, 0, -1].mean()
243 print(f'{naming_scheme} {name}: mAP@50={prec * 100: 05.1f}, ' +
244 f'score={scores.mean():0.3f}, ' +
245 f'f1={2 * prec * rec / (prec + rec + 1e-8):0.3f}'
246 )
247 axs[0].plot(recall, precision, c=color)
248 axs[1].plot(recall, scores, c=color)
249
250 axs[0].set_title('Precision / Recall')
251 axs[0].legend(names)
252 axs[1].set_title('Scores / Recall')
253 axs[1].legend(names)
254 return fig, axs
255
256def plot_3d(xdata, ydata, zdata, color=None, b_min=-5, b_max=5, view=(45, 45)):
257 plt.figure(1); plt.clf()

Callers

nothing calls this directly

Calls 1

printFunction · 0.70

Tested by

no test coverage detected