-
Notifications
You must be signed in to change notification settings - Fork 124
Implement Adjusted mutual information #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #287 +/- ##
==========================================
+ Coverage 95.40% 95.50% +0.09%
==========================================
Files 20 20
Lines 1503 1556 +53
==========================================
+ Hits 1434 1486 +52
- Misses 69 70 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thank you for the contribution! I think it would be useful addition.
|
Thanks for the quick feedback! Regarding your first point, isn’t that breaking? And how should I deal with the 4 variants of the adjusted mutual information? Have one symbol for each? (And another that’s just And good point about |
I am thinking about something like mutualinfo(a, b; method = :classic, kwargs...) = _mutualinfo(Val{method}, a, b; kwargs...)
function _mutualinfo(::Val{:classic}, a, b; normed::Bool = true)
....
end
function _mutualinfo(method::Val, a, b; kwargs...)
if method[] == :adjusted
error("mutualinfo(..., method=:adjusted) requires SpecialFunctions package")
else
error("mutualinfo(): method=$(method) is not supported")
end
end and then in the extension function _mutualinfo(::Val{:adjusted}, a, b; aggregate::Symbol = :mean)
....
end So since the default method value is |
@alyst I made the changes you suggested with a few adjustments. The As for the value to use for the regular Mutual Information, The 1.0 test is failing because |
Thank you!
I think it is better to raise ArgumentError if method == :normalized and normed == false. Also, if normed kwarg is in the generic Regarding
Extensions will require us to bump Julia requirement to 1.8 (and we can use backward compatibility packages to support earlier versions, probably 1.6 LTS) -- which is reasonable, given how outdated 1.0 is by now. |
Since I removed the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements adjusted mutual information by expanding the mutualinfo API to support additional methods and aggregates while deprecating the old normed parameter. Key changes include:
- Updates in the tests (test/mutualinfo.jl) to cover classic, normalized, and adjusted mutual information methods along with error cases.
- Refactoring of src/mutualinfo.jl to support method dispatch based on a new keyword argument and integration of adjusted mutual information.
- Introduction of a new module (ext/SpecialFunctionsExt.jl) to handle the adjusted MI computation and conditional inclusion in src/Clustering.jl.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/runtests.jl | Added the SpecialFunctions import to support tests with adjusted mutual information. |
test/mutualinfo.jl | Expanded tests to cover multiple mutual information methods and error conditions. |
src/mutualinfo.jl | Modified API and internal dispatch to support a new :adjusted method with aggregates. |
src/Clustering.jl | Added conditionally including the SpecialFunctionsExt.jl module based on Base definition. |
ext/SpecialFunctionsExt.jl | New module for adjusted mutual information computation using SpecialFunctions. |
Also a couple of clarity fixes
@alyst This is ready to merge and tests are passing! Changes I've made since the review:
|
I may have gone overboard with the code reuse. I can refactor if needed.