= PredictiveAccuracy()
acc = fake_explanation(3)
exp acc(exp)
Array(0.98300004, dtype=float32)
class relax.evaluate.BaseEvalMetrics (name=None)
Base evaluation metrics class.
class relax.evaluate.PredictiveAccuracy (name=‘accuracy’)
Compute the accuracy of the predict function.
relax.evaluate.compute_validity (xs, cfs, pred_fn)
Parameters:
<class 'jax.Array'>
) – (n, d)<class 'jax.Array'>
) – (n, d) or (n, b, d)typing.Callable[[jax.Array], jax.Array]
)Returns:
(<class 'float'>
)
relax.evaluate.compute_single_validity (xs, cfs, pred_fn)
Parameters:
<class 'jax.Array'>
) – (n, d)<class 'jax.Array'>
) – (n, d)typing.Callable[[jax.Array], jax.Array]
)class relax.evaluate.Validity (name=‘validity’)
Compute fraction of input instances on which CF explanation methods output valid CF examples. Support binary case only.
relax.evaluate.compute_proximity (xs, cfs)
relax.evaluate.compute_single_proximity (xs, cfs)
class relax.evaluate.Proximity (name=‘proximity’)
Compute L1 norm distance between input datasets and CF examples divided by the number of features.
relax.evaluate.compute_sparsity (xs, cfs, feature_indices)
relax.evaluate.compute_single_sparsity (xs, cfs, feature_indices)
class relax.evaluate.Sparsity (name=‘sparsity’)
Compute the number of feature changes between input datasets and CF examples.
class relax.evaluate.ManifoldDist (n_neighbors=1, name=‘manifold_dist’)
Compute the L1 distance to the n-nearest neighbor for all CF examples.
class relax.evaluate.Runtime (name=‘runtime’)
Compute the runtime of the CF explanation method.
relax.evaluate.evaluate_cfs (cf_exp, metrics=None, return_dict=True, return_df=False)
Parameters:
<class 'relax.explain.Explanation'>
) – CF Explanationstyping.Iterable[typing.Union[str, __main__.BaseEvalMetrics]]
, default=None) – A list of Metrics. Can be str
or a subclass of BaseEvalMetrics
<class 'bool'>
, default=True) – return a dictionary or not (default: True)<class 'bool'>
, default=False) – return a pandas Dataframe or not (default: False)relax.evaluate.benchmark_cfs (cf_results_list, metrics=None)