Skip to content

Commit

Permalink
Merge pull request #512 from JuliaTrustworthyAI/counterfactual-method…
Browse files Browse the repository at this point in the history
…-for-flattened

done
  • Loading branch information
pat-alt authored Jan 13, 2025
2 parents b4b0527 + 1a4dc7a commit eab93a0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

*Note*: We try to adhere to these practices as of version [v1.1.1].

## Version [1.4.5] - 2025-01-13

### Changed

- Dispatching `factual` and `counterfactual` over `AbstractCounterfactualExplanation` instead of `CounterfactualExplanation`. [#512]
- Added type conversion to `compute_divergence`. [#512]

## Version [1.4.4] - 2025-01-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CounterfactualExplanations"
uuid = "2f13d31b-18db-44c1-bc43-ebaf2cff0be0"
authors = ["Patrick Altmeyer <p.altmeyer@tudelft.nl> and contributors"]
version = "1.4.4"
version = "1.4.5"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down
8 changes: 4 additions & 4 deletions src/counterfactuals/info_extraction.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
factual(ce::CounterfactualExplanation)
factual(ce::AbstractCounterfactualExplanation)
A convenience method to retrieve the factual `x`.
"""
function factual(ce::CounterfactualExplanation)
function factual(ce::AbstractCounterfactualExplanation)
return ce.factual
end

Expand All @@ -29,11 +29,11 @@ function factual_label(ce::CounterfactualExplanation)
end

"""
counterfactual(ce::CounterfactualExplanation)
counterfactual(ce::AbstractCounterfactualExplanation)
A convenience method that returns the counterfactual.
"""
function counterfactual(ce::CounterfactualExplanation)
function counterfactual(ce::AbstractCounterfactualExplanation)
return ce.counterfactual
end

Expand Down
5 changes: 4 additions & 1 deletion src/evaluation/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,10 @@ function compute_divergence(
_df.pval .= NaN
else
metric = measure[String.(measure_name.(measure)) .== unique(_df.variable)[1]][1]
val, pval = metric(collect(_df.ce), data)
ces =
collect(_df.ce) |>
ces -> [convert(AbstractCounterfactualExplanation, ce) for ce in ces]
val, pval = metric(ces, data)
_df.value .= val
_df.pval .= pval
end
Expand Down

2 comments on commit eab93a0

@pat-alt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/122916

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.5 -m "<description of version>" eab93a0e4e218e51f52f97ffc0ebcb99dd5fe376
git push origin v1.4.5

Please sign in to comment.