-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add spatial visualisations for decision matrices #893
base: main
Are you sure you want to change the base?
Conversation
@Rosejoycrocker this PR has a conflict and the tests are not passing. About the tests, this could be due to a problem that was fixed yesterday, not sure. |
…readable criteria names for labels Plus add criteria names as optional inputs so less than total set of criteria can be plotted
Allows scores to be calculated separately for analysis
a8c0896
to
d72ce02
Compare
I'm looking into it now |
Remove incorrect additions from rebase
16daef5
to
7e26a3e
Compare
Tests are passing and conflicts reolved now @Zapiano :) |
@@ -131,6 +131,30 @@ Index of locations ordered by their rank | |||
function rank_by_index( | |||
dp::T, dm::YAXArray, method::Union{Function,DataType} | |||
)::Vector{Int64} where {T<:DecisionPreference} | |||
res = get_criteria_aggregate(dp, dm, method) |
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.
I imagine res
comes from result
, right? Everything any function returns is a result (the result of that function), so calling a variable result
is a little bit vague (maybe with a few exceptions). Maybe calling it aggregate_score
or something else that helps the reader would be better.
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.
Its a result structure that the MCDA package uses, so it contains more than just the aggregate score. Maybe change it to decision_results
or something?
@@ -131,6 +131,30 @@ Index of locations ordered by their rank | |||
function rank_by_index( |
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.
This function signature doesn't match the docstring (I know this wasn't updated by you, if you prefer just open an issue to fix that on a separate PR).
# Returns | ||
Returns raw aggreagted score for a set of locations | ||
""" | ||
function get_criteria_aggregate( |
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.
-
You say this function returns a
raw aggregated score for a set of locations
, so maybe it could be calledaggregated_scores
orcriteria_aggregated_scores
? I just think thisget
part of the name may be a little redundant. And, since you are aggregating scores, adding the wordscores
at the end may clarify what this returns. -
The function signature doesn't match the docstring.
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.
Thanks for spotting, I'll fix the signature and change the name to criteria_aggregated_scores
@@ -251,6 +256,75 @@ function ADRIA.viz.map!( | |||
axis_opts | |||
) | |||
end | |||
function ADRIA.viz.map( |
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.
Since map
is a very generic name, I don't think we should make a method called map
plot a specific kind of map only (only maps of decision matrix scores). What I mean is: it is interesting to have a map
function that plots multiple maps like you did, but not only for decision matrix. I could plot the average of some different metrics for each location, for example.
So, I propose we have an intermediate function selection_criteria_map
, for example, that receives this matrix and this vector, concatenate them to become just a single matrix; builds up a tuple of titles for each plot; and call a map
function that receives this matrix and the titles_tuple
(and whatever else it needs) and plots this grid of maps. Then, in the future, if we want to plot other multiple map figure, it can be easily reused.
What do you think?
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.
Sounds good :)
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.
I prefer the current approach but I'm not 100% up on the context here, just latching onto the suggestion to create a separate map plotting function. Julia is not strictly an object oriented language and isn't intended to be used like Python or Java.
The advantage of having multiple dispatch (or something like it, as in R) is to prevent everyone from having to remember a lot of function names. Is it map
or vizualize_selection_criteria_as_map
or display_map
or plot_selection_criteria_map
or...
As a user I don't want to have to remember endless possible function names for specific use cases. I just want a map.
Instead, this behaviour of:
- You have a vector of results ->
map()
produces a single map. - You have a matrix of results ->
map()
produces a series of maps.
is sensible to me.
But again, I don't have full context.
https://www.juliaopt.org/meetings/santiago2019/slides/stefan_karpinski.pdf
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.
I understand and I agree with what you said.
My problem with how this function is defined right now is that it doesn't plot selection criteria scores in particular. It plots multiple maps with whatever you pass as an argument. But still the names of variables and the plots default titles are related to this specific kind of plot (multiple maps with selection criteria scores). It's like having a function called sum
and the arguments are called prime_number_a
and prime_number_b
. If it sums more than just prime numbers, they should be called number_a
and number_b
or whatever.
About the need for a specific function called selection_criteria_map
, maybe we don't need one, I agree. depending on how this map
function with multiple maps is defined we can just use this one and that's fine. My comment was more about making this map
general than about the need of a specific function with a specific name for this kind of plot.
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.
Incidentally @Rosejoycrocker the variable names/titles displayed in the figure should be run through human_readable()
(this isn't the exact function name but you should be able to find it easily)
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.
I'm not sure what the outcome of this discssuion is, but I've separated this into a generic map() method which plots multiple maps in a grid given a matrix of inputs, and then a function in location_selection.jl that plots criteria and an aggregate score given a decision matrix input and vector of scores (using the generic map() function). Not sure what you think but I think being able to quickly plot criteria and an output score is useful, hence its inclusion in location_selection.jl.
ext/AvizExt/viz/spatial.jl
Outdated
@@ -251,6 +256,75 @@ function ADRIA.viz.map!( | |||
axis_opts | |||
) | |||
end | |||
function ADRIA.viz.map( | |||
rs::Union{Domain,ResultSet}, | |||
M::YAXArray, |
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.
- This doesn't match the docstring.
- I am against naming variables with a single letter except in very specific cases. You have little to gain and everyone that reads you code (including your future self) have a lot of time to lose with this. :)
One is generic matrix mapping, the other is specifically for mapping criteria and aggregate scores
Fix function signatures
Update function signatures
8e5dcb3
to
409bfba
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #893 +/- ##
==========================================
- Coverage 51.44% 51.14% -0.31%
==========================================
Files 72 72
Lines 4782 4818 +36
==========================================
+ Hits 2460 2464 +4
- Misses 2322 2354 +32 ☔ View full report in Codecov by Sentry. |
15e7273
to
841bece
Compare
Formatting Put func docstrings on single lines
841bece
to
1a677cc
Compare
I think I've addressed your comments @Zapiano , let me know if you have others |
Adds method to viz.map for plotting decision matrices and aggregate scores on a set of side-by-side maps.