Get started with Obz AI
obzai
library, try:
AttentionMap
makes it easy for you to obtain attention maps regardless of the ViT architectures.
In particular, we support models with and without [CLS]
token.
In general, AttentionMap
expects a model that returns attention weights, like the transformers package.
CDAM is a gradient-based extension of attention map that provides class-discriminative feature importances.
Within CDAM
, there are several several optional arguments which allows you to apply related XAI methods.
Argument | Options (default: bold) | Note |
---|---|---|
mode | ”vanilla”, “smooth”, “integrated” | ------- |
gradient_type | ”from_logits”, “from_probabilities” | ------- |
gradient_reduction | ”dot_product”, “average”, “sum” | ------- |
activation_type | ”softmax”, “sigmoid” | ------- |
noise_level | 0.05 | Only applicable to “smooth” |
num_steps | 50 | Only applicable to “integrated” |
SaliencyMap
class can be configured with the following arguments:
Argument | Options (default: bold) | Note |
---|---|---|
mode | ”vanilla”, “smooth” | ------- |
nt_type | ”smoothgrad”, “smoothgrad_sq”, “vargrad” | ------- |
nt_samples | 10 | nt: noise type |
XAIRegions
:
fidelity_tool
measures how accurately a given XAI method reflects the model’s true decision process. It does this by systematically perturbing input features based on their importance scores and observing the resulting change in the model performance.
compactness_tool
evaluates how sparse and concentrated the importance scores are. A more compact set of importance scores is often easier for humans to interpret, as it highlights the most relevant features in a concise manner.
By using these tools, you can better understand and compare the effectiveness and interpretability of different XAI approaches.
DataLoader
from PyTorch, e.g.,:First Order Features
which are modeled by
a Gaussian Mixture Models (GMMs).
Load and instantiate outlier detectors:
GMMDetector
is an outlier detection method that utilizes a Gaussian Mixture Model (GMM). To configure and use the GMMDetector
, consider the following arguments:
extractors
- Sequence of Extractor objects which process your data. Currently, only the FirstOrderExtractor
is accepted.n_components
- A number of Gaussian components for the mixture model. This controls the complexity of the model and how finely it can separate data clusters.outlier_quantile
- Set the quantile threshold to determine what is considered an outlier. Data points falling below this quantile are classified as outliers.show_progress
- If set to True
, a progress bar will be displayed during feature extraction to visualize operation progress.ObzClient
to make seamless connection and monitoring from the Obz AI dashboard..detect()
method. This method returns a named tuple with:
img_features
- extracted features for each image in the batch.outliers
- boolean vector indicating if samples in the batch are outliers.ObzClient
ObzClient
OutlierDetector
instance and XAITool
instances, you are ready to wrap it into your ObzClient
!api_key
into client’s method .login()
..netrc
file, so you don’t need to more provide your API key to authenticate ObzClient
!.init_project()
method. This method accepts following arguments:
project_name
- Project to which you would like to connect ObzClient instance. If you provide a brand new project, it will create it.ml_task
- Type of your ML task. We need it to adjust your project such as “binary_classification”, “multiclass_classification”, etc.index2name
- (Optional) We recommend passing also index to name mapping, to visualize correctly class names in your dashboard.client.run_and_log
automatically runs outlier detection and XAI algorithms specified earlier: