What's Changed 🚀
For more transparent kwargs-passing and error handling, we have updated the API of Quantus! The main changes are the following:
- Add function-specific keyword-arguments to metric functions. by dkrako in https://github.com/understandable-machine-intelligence-lab/Quantus/pull/124
**From implicit to explicit argument passing.** To mitigate the risk of user typos and other undefined behaviours, the new version `0.2.0` forces explicit argument passing of all metric initalisations and calls. Instead of passing all evaluation parameters in one single kwargs list, e.g.,
python
kwargs = {"n_perturb_samples": 10, "abs": False, "normalise": True, "explain_func": quantus.explain, method: "Saliency"}}
metric = Infidelity(**kwargs)
metric(model=model, x_batch=x, y_batch=y, a_batch=a, s_batch=s, **kwargs)
which could for example result in typos being overlooked, we now separate the parameters into different dictionaries such as `normalise_func_kwargs`, `explain_func_kwargs`, `model_predict_kwargs`. With the new API, the same call looks like this:
python
metric = Infidelity(n_perturb_samples=10, abs=False, normalise=True)
metric(model=model, x_batch=x, y_batch=y, a_batch=a, s_batch=s, explain_func=quantus.explain, explain_func_kwargs={"method": "Saliency"})
In this way, we assert better control over the parameters. If an unexpected argument is passed, an error will now be thrown.
**Extended the `base.Metric` class.** Many metrics share the same logic when it comes to general attributes and pre-processing. To remove duplicate code, we extended the base class, which now includes some key methods `general_preprocessing`, `custom_preprocessing`, `evaluate_instance`, `custom_postprocessing` all which could be used for various `Metric` implementations.
**Additional functionality in helpers and increased general code-quality.** We have shortended and rewritten scripts where necessary for better code readability. Added new functions and refactored existing ones to adhere to [PEP-8](https://www.python.org/dev/peps/pep-0008/).
If these API changes are not suitable for your project's needs, please install a previous release version such as [v0.1.6](https://github.com/understandable-machine-intelligence-lab/Quantus/releases/tag/v0.1.6) via:
bash