greenelab / word-lapse

Explore how a word changes over time
https://greenelab.github.io/word-lapse/
Other
6 stars 3 forks source link

implemented a umap trajectory feature #47

Closed danich1 closed 2 years ago

danich1 commented 2 years ago

This PR implements the backed to propagate umap coordinates onto the frontend to provide users an alternative way to see how neighborhoods are shifting. I received feedback that this feature may help some audience understand the word neighbor changes. My code works locally, but there may be an issue when its fully implemented onto the online server.

In regards to the front-end, I'm envisioning a simple scatter plot each point is a token and they have their corresponding labels next to them. The query token would have a new shape or some indication that this was the token they queried and lastly, an arrow to show the trajectory path (tok_2000 -> tok_2001...-> tok_2021).

The returned object is now in the form of:

  {
        "neighbors": {<year:str>: [<token:str>, ...]},
        "umap_coords": [{"year":<year:int>, "is_query":<is_query:bool>, "token":<token:str> ,"umap_x_coord":<umap_x_coord:float>, "umap_y_coord":<umap_y_coord:float>}, ...],
        "frequency": [{"year": <year:int>, "frequency": <frequency:float>}, ...],
        "changepoints": [ [<year_start:str>, <year_end:str>], ...],
        "elapsed": <elapsed_ms:float>
    }
netlify[bot] commented 2 years ago

Deploy Preview for word-lapse canceled.

Name Link
Latest commit 0d7674ca7420302dc24528620e485b5d71b703df
Latest deploy log https://app.netlify.com/sites/word-lapse/deploys/6262e9cc26041200088c962f
vincerubinetti commented 2 years ago

Nice, could you post some sample json just for the umap. I have time today to start working on the visualization.

danich1 commented 2 years ago

Here is an example demo json. The tokens aren't de-identified; however, they will be in the actual implementation. umap_demo.json.txt