Skip to content
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 H-score as output value #81

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Add H-score as output value #81

merged 1 commit into from
Jan 22, 2025

Conversation

woodthom2
Copy link
Contributor

Description

#41

Ideally Harmony could say that e.g. the GAD-7 is e.g. 60% similar to the PHQ-9

See Colab notebook on WMD (Word Movers Distance):
https://github.com/harmonydata/experiments/blob/main/harmony_wmd_experiment.ipynb

I tried coming up with a way of scoring the instrument vs instrument similarity since this has been discussed a number of times.
I wanted to find a way of going from the matrix of cosine scores, to a similarity between two instruments.
I put my experiments here:
https://github.com/harmonydata/h_score/blob/main/experiment_with_different_h_score_metrics.ipynb

I could not think of a coherent way of describing this in an email, but we can discuss at some point.

I think I have an acceptable way of calculating the instrument vs instrument cosine similarity, which is basically getting the crosswalk table, and averaging the values in it, and dividing by the number of items that should have been matched.
My conditions are that:

  1. if you remove a question e.g. match the first six questions of GAD-7 vs the whole GAD-7, you should get a score about 6/7
  2. if you reverse the items in a questionnaire, it should still match 100%
  3. I made a gold standard where I defined what I think the score should be for a few combinations like this, e.g. GAD-7 vs CES-D should be about 50%. Of course this is subjective and we can adjust it.

If we do this, we can get two measures of similarity between instruments - since one instrument may have 100 items and one instrument has 10, the similarity is not symmetric, so my formula that I'm proposing gives us a separate similarity metric in both directions (I called them precision and recall, since that's the terminology used in NLP when you have a query and you are trying to retrieve a document), and we can average them to get an overall similarity metric (called the F1 score, also a term that is used in NLP for the mean of precision and recall).

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Requires a documentation revision

Testing

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • test_instrument_to_instrument_similarity.py

Since the Harmony Python package is used by the Harmony API (which is itself used by the R library and the web app), we need to avoid making any changes that break the Harmony API. Please also run the Harmony API unit tests and check that the API still runs with your changes to the Python package: https://github.com/harmonydata/harmonyapi

Test Configuration

  • Library version: 1.0.1
  • OS: Ubuntu
  • Toolchain: Pycharm

Checklist

  • My code follows the style guidelines of this project. I have applied a Linter (recommended: Pycharm's code formatter) to make my whitespace consistent with the rest of the project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • The Harmony API is not broken by my change to the Harmony Python library - see near simultaneous commit in API library
  • I add third party dependencies only when necessary. If I changed the requirements, it changes in requirements.txt, pyproject.toml and also in the requirements.txt in the API repo
  • If I introduced a new feature, I documented it (e.g. making a script example in the script examples repository so that people will know how to use it.

Optionally: feel free to paste your Discord username in this format: discordapp.com/users/yourID in your pull request description, then we can know to tag you in the Harmony Discord server when we announce the PR.

@woodthom2
Copy link
Contributor Author

See associated task to implement in front end harmonydata/app#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant