MDS: supply Gram matrix directly
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- julia
- Domain
- data-visualization
Research direction
Start by locating the existing MDS fit entry points and the dmat2gram and gram2dist conversions mentioned in the issue. Compare the current coordinate and distance paths before settling the input-tagging API; done means direct Gramian input is supported without breaking existing behavior.
Written by the indexing model from the issue text.
Description
Currently the pipeline for MDS is X -> D -> G -> M, where X is a coordinate representation of the data, D is the pairwise distance matrix, G is the Gram matrix, and M is the final MDS model. One can alternatively go D -> G -> M by supplying the distances=true keyword. However, there are applications where the natural thing to supply is G. For example, if you are working with objects for which there is a natural inner product, and you want to visualize these objects in a lower-dimensional space, you're going to first compute G, and it would be quite silly to use fit(MDS, gram2dist(G); distances=true) when the first thing that will happen inside fit is to convert the distances back into the Gram matrix.
I know there isn't a ton of stuff inside fit that happens after you have G, but from the standpoint of keeping things in sync I think it would be best to expose this to the user instead of forcing them to create their own private version of fit.
The only hard problem is deciding the API. I think a good design would be
struct Distances{M<:AbstractMatrix}
D::M
end
struct Gramian{M<:AbstractMatrix}
G::M
end
fit(::Type{MDS}, X::AbstractMatrix) = fit(MDS, Distances(L2distance(X)))
fit(::Type{MDS}, D::Distances) = fit(MDS, Gramian(dmat2gram(D.D)))
function fit(::Type{MDS}, G::Gramian)
# the "main" implementation
end
Then users call one of:
fit(MDS, X)fit(MDS, Distances(D))fit(MSD, Gramian(G))
depending on what kind of starting point they have.
One alternative approach is to use a keyword argument, but here we would run into a compatibility problem: if we add gramian::Bool=false as a keyword, then we have to look for the case where distances == gramian == true and throw an error. This is not a big deal but it feels a bit ugly. Alternatively we could add interpretation=:coordinates and support the settings :distances and :gramian but that would be a breaking change. We can do a breaking change, but it seems to be a bit silly for a very minor change. With the "type tagging" of the input data, we could have fit(::Type{MDS}, X::AbstractMatrix) still support the distances kwarg but give a deprecation warning, and then we can remove that API whenever other more substantive changes force a breaking release.
- Dominant language
- Julia
- Stars
- 387
- Forks
- 83
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaStats/MultivariateStats.jl
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
tagbot-manual
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
JuliaStats/MultivariateStats.jl#238 · 1 comment ·
-
Return a result even when MetricMDS does not convergePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
JuliaStats/MultivariateStats.jl#233 · 1 comment ·
-
How to use MetricMDSOpen
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
JuliaStats/MultivariateStats.jl#231 · 2 comments ·
All issues in JuliaStats/MultivariateStats.jl
Similar issues
-
Affine transformations of `JohnsonSU` could return a `JohnsonSU`Possibly taken @devmotion claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaStats/Distributions.jl#2117 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
TomerAberbach/profiler-md#970 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
grame-cncm/faust#1409 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
SciML/PETScDiffEq.jl#521 ·
Maintainers usually reply within 1 day