Plots
plot_2D_features(model, in_dataset, output_layer_id, out_dataset=None, proj_method='TSNE', max_samples=4000, title=None, **proj_kwargs)
¶
Visualize ID and OOD features of a model on a 2D plan using dimensionality reduction methods and matplotlib scatter function. Different projection methods are available: TSNE, PCA.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Callable
|
Torch or Keras model. |
required |
in_dataset |
DatasetType
|
In-distribution dataset (torch dataloader or tf dataset) that will be projected on the model feature space. |
required |
output_layer_id |
Union[int, str]
|
Identifier for the layer to inspect. |
required |
out_dataset |
DatasetType
|
Out-of-distribution dataset (torch dataloader or tf dataset) that will be projected on the model feature space if not equal to None. Defaults to None. |
None
|
proj_method |
str
|
Projection method for 2d dimensionality reduction. Defaults to "TSNE", alternative: "PCA". |
'TSNE'
|
max_samples |
int
|
Max samples to display on the scatter plot. Defaults to 4000. |
4000
|
title |
str
|
Custom figure title. Defaults to None. |
None
|
Source code in oodeel/eval/plots/features.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
plot_3D_features(model, in_dataset, output_layer_id, out_dataset=None, proj_method='TSNE', max_samples=4000, title=None, **proj_kwargs)
¶
Visualize ID and OOD features of a model on a 3D space using dimensionality reduction methods and matplotlib scatter function. Different projection methods are available: TSNE, PCA.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Callable
|
Torch or Keras model. |
required |
in_dataset |
DatasetType
|
In-distribution dataset (torch dataloader or tf dataset) that will be projected on the model feature space. |
required |
output_layer_id |
Union[int, str]
|
Identifier for the layer to inspect. |
required |
out_dataset |
DatasetType
|
Out-of-distribution dataset (torch dataloader or tf dataset) that will be projected on the model feature space if not equal to None. Defaults to None. |
None
|
proj_method |
str
|
Projection method for 2d dimensionality reduction. Defaults to "TSNE", alternative: "PCA". |
'TSNE'
|
max_samples |
int
|
Max samples to display on the scatter plot. Defaults to 4000. |
4000
|
title |
str
|
Custom figure title. Defaults to None. |
None
|
Source code in oodeel/eval/plots/features.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
plot_ood_scores(scores_in, scores_out, log_scale=False, title=None)
¶
Plot histograms of OOD detection scores for ID and OOD distribution, using matplotlib and seaborn.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores_in |
ndarray
|
OOD detection scores for ID data. |
required |
scores_out |
ndarray
|
OOD detection scores for OOD data. |
required |
log_scale |
bool
|
If True, apply a log scale on x axis. Defaults to False. |
False
|
title |
str
|
Custom figure title. If None a default one is provided. Defaults to None. |
None
|
Source code in oodeel/eval/plots/metrics.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
plot_roc_curve(scores_in, scores_out, title=None)
¶
Plot ROC curve for OOD detection task, using matplotlib and seaborn.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores_in |
ndarray
|
OOD detection scores for ID data. |
required |
scores_out |
ndarray
|
OOD detection scores for OOD data. |
required |
title |
str
|
Custom figure title. If None a default one is provided. Defaults to None. |
None
|
Source code in oodeel/eval/plots/metrics.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
plotly_3D_features(model, in_dataset, output_layer_id, out_dataset=None, proj_method='TSNE', max_samples=4000, title=None, **proj_kwargs)
¶
Visualize ID and OOD features of a model on a 3D space using dimensionality reduction methods and matplotlib scatter function. Different projection methods are available: TSNE, PCA. This function requires the package plotly to be installed to run an interactive 3D scatter plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Callable
|
Torch or Keras model. |
required |
in_dataset |
DatasetType
|
In-distribution dataset (torch dataloader or tf dataset) that will be projected on the model feature space. |
required |
output_layer_id |
Union[int, str]
|
Identifier for the layer to inspect. |
required |
out_dataset |
DatasetType
|
Out-of-distribution dataset (torch dataloader or tf dataset) that will be projected on the model feature space if not equal to None. Defaults to None. |
None
|
proj_method |
str
|
Projection method for 2d dimensionality reduction. Defaults to "TSNE", alternative: "PCA". |
'TSNE'
|
max_samples |
int
|
Max samples to display on the scatter plot. Defaults to 4000. |
4000
|
title |
str
|
Custom figure title. Defaults to None. |
None
|
Source code in oodeel/eval/plots/plotly.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|