Mutating labels when training MulticlassLDA

Open
#205 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia

Research direction

Start at src/lda.jl around line 522 and inspect how toindices handles integer labels during MulticlassLDA training and decoding. Reproduce the separate-training-and-test case, including labels with gaps, and verify that converting labels does not mutate the caller's labels or randomize class assignments.

Written by the indexing model from the issue text.

Description

This recent change really threw a wrench into my pipeline:
https://github.com/JuliaStats/MultivariateStats.jl/blob/bf15ed047bb44dc3f2ebc5db73a9b43df3a55059/src/lda.jl#L522

I am training LDAs on one set of trials and testing the decoding performance on a separate set of trials. All of a sudden, my performance dropped to chance and after about a day of digging around, I realised that toindices actually mutates the label names. In other words, when I was decoding the testset by finding the projected mean that each sample was closest to, I was using the original labels for my testing, and so the class assignments were all essentially random.

As a stopgap measure for my pipeline, I defined

MultivariateStats.toindices(label::AbstractVector{T}) where T <: Integer = label

which fixed my issue, but I realise that this is not general solution. In particular, if there are gaps in label, such that maximum(label) !== length(unique(label)), this could also cause problems.
Is there currently an array type that fulfils that criteria?

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaStats/MultivariateStats.jl

All issues in JuliaStats/MultivariateStats.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.