Skip to content

Commit

Permalink
refactor code, change readme
Browse files Browse the repository at this point in the history
  • Loading branch information
defo10 committed Sep 15, 2021
1 parent 14e7278 commit f65602d
Show file tree
Hide file tree
Showing 46 changed files with 21,587 additions and 10,337 deletions.
1 change: 1 addition & 0 deletions .eslintcache

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"rules": {
// note you must disable the base rule as it can report incorrect errors
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"]
"@typescript-eslint/no-use-before-define": ["error"],
"camelcase": "off",
"@typescript-eslint/camelcase": ["off"],
"eqeqeq": "warn",
"space-before-function-paren": "off"
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Grant Custer
Copyright (c) 2021 Daniel Stachnik

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
Code for an interactive [UMAP](https://github.com/lmcinnes/umap) visualization of the MNIST data set. Demo at [https://grantcuster.github.io/umap-explorer/](https://grantcuster.github.io/umap-explorer/). You can read more about the demo in [the about section](https://grantcuster.github.io/umap-explorer/#about).
# Interactive Visualization Interface for Text Exploration and Annotation

This project was created for my bachelor thesis. It builds on top of the (UMAP Explorer)[https://github.com/GrantCuster/umap-explorer] and was used as a prototype to elicit explanation needs of users. To find out more, check out the (thesis)[thesis/thesis_main.pdf].

## A rough guide to the code

The demo app is a React app. It uses a `src/Data.js` to fetch the data and `src/Layout.js` to handle the layout of the page. The three.js visualization code is in `src/Projection.js`. The texture atlases are in the public folder as images. I also included the iPython notebook files I used to generate the texture atlases (`making_mnist_images.ipynb`) and to download the UMAP embeddings (`plot_mnist_example.ipynb`).
![uml class diagram](uml/components.png)

The demo app is a React app. It uses `src/Data.js` to fetch the data and `src/Layout.js` to handle the layout of the page. The three.js visualization code is in `src/Projection.js`. The data is available as json files in the `public` folder. The data was created using a text processing pipeline developed at HCI lab of FU Berlin.

## Running the demo page

Open defo10.github.io/interface-for-text-exploration-and-annotation

## Running the app
## Running the app locally

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

Expand Down
21,211 changes: 21,202 additions & 9 deletions package-lock.json

Large diffs are not rendered by default.

296 changes: 0 additions & 296 deletions plot_mnist_example.ipynb

This file was deleted.

70 changes: 0 additions & 70 deletions src/About.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

File renamed without changes.
57 changes: 0 additions & 57 deletions src/Content.js

This file was deleted.

12 changes: 7 additions & 5 deletions src/Data.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { constants } from 'buffer'
// this class is responsible for loading all data
// and parsing it into the right format
import * as d3 from 'd3'
import * as _ from 'lodash'
import lunr from 'lunr'
Expand Down Expand Up @@ -192,10 +193,10 @@ export default class Data extends Component<any, State> {
pushToDataChanged (newData: DataChanged) {
const alreadyExisting = _.find(this.state.dataChanged, ['i', newData.i])
const newDataChanged = _.without(this.state.dataChanged, alreadyExisting)
if (!(
alreadyExisting && alreadyExisting.oldLabel.label_kmedoids == newData.newLabel.label_kmedoids || // if users reverts change, skip
!alreadyExisting && newData.oldLabel.label_kmedoids == newData.newLabel.label_kmedoids // if wasnt changed before but has no change either, skip
)) newDataChanged.push(newData)

const userRevertedChange = alreadyExisting && alreadyExisting.oldLabel.label_kmedoids == newData.newLabel.label_kmedoids
const noChange = !alreadyExisting && newData.oldLabel.label_kmedoids == newData.newLabel.label_kmedoids
if (!userRevertedChange || noChange) newDataChanged.push(newData)

// if new cluster, set clusters
if (!this.state.clusters[newData.newLabel.label_kmedoids]) {
Expand Down Expand Up @@ -505,6 +506,7 @@ export default class Data extends Component<any, State> {

const distances = coordinates.map(
(coord) => {
// eslint-disable-next-line array-callback-return
if (this.state.labels?.[coord.index].label_kmedoids != label) return
// is of same cluster:
const sqrd_eucl_dist = Math.sqrt(Math.pow(coord.x - medoid_pos.x, 2) + Math.pow(coord.y - medoid_pos.y, 2))
Expand Down
Loading

0 comments on commit f65602d

Please sign in to comment.