Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added TrElections.npz
Binary file not shown.
2 changes: 1 addition & 1 deletion demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@
"# this calculates the micro f1 score for all umap configurations in the grid search\n",
"# and plots the result of each configuration\n",
"# then returns the results matrix and a heatmap plot of it\n",
"results, hm = cluster_projection_grid_search(\n",
"results, hm = Clusterer.cluster_projection_grid_search(\n",
" \"trials\", users=labels.username, labels=labels.label,\n",
" # this means multiple clusters can be assigned the same label\n",
" allow_multiple_clusters=True\n",
Expand Down
Binary file modified src/__pycache__/clustering.cpython-36.pyc
100755 → 100644
Binary file not shown.
Binary file modified src/__pycache__/projection.cpython-36.pyc
100755 → 100644
Binary file not shown.
10 changes: 6 additions & 4 deletions src/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def plot_tree(path):
return pickle.load(open(path, 'rb')).plot()

def plot(self, labels_col="clusters"):
sns.set(context='notebook', style='white', rc={'figure.figsize': (15, 15)})
return Projector.plot(embeddings=self._params["umap"], labels=self._params[labels_col])

def inject_labels(self, users, labels):
Expand All @@ -70,7 +71,7 @@ def align_clusters_with_labels(self, allow_multiple_clusters=True):
labels = labels[ind]

df = pd.DataFrame(
{"username": users, "labels": labels}
{"username": users, "label": labels}
).merge(
pd.DataFrame({"username": self._params["users"], "clusters": self._params["clusters"]})
)
Expand Down Expand Up @@ -108,7 +109,7 @@ def evaluate(self, metric=f1_score, report=True):
y = y[ind]
p = p[ind]

s = set(y)
s = list(set(y))
if report:
return pd.DataFrame(classification_report(y, p, labels=s, output_dict=True))

Expand All @@ -132,7 +133,8 @@ def cluster_projection_grid_search(trials_dir, users=None, labels=None, allow_mu
plt.savefig(plot_path, bbox_inches='tight')
plt.close()

score = c.evaluate()
score = c.evaluate(report=False)
results.setdefault(min_dist, dict())
results[min_dist][n_neighbors] = score
return results
return results, Projector.plot_grid_search_heatmap(results,
heatmap_destination=os.path.join(trials_dir, 'hm.png'))
12 changes: 12 additions & 0 deletions src/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np

from clustering import Clusterer, pickle
from projection import Projector, os

f = np.load("../TrElections.npz")

results, hm = Clusterer.cluster_projection_grid_search(
f"../umap4_trials", users=f["users"], labels=f["labels"],
# this means multiple clusters can be assigned the same label
allow_multiple_clusters=True
)
Binary file added umap3_trials/0.0_100.npz
Binary file not shown.
Binary file added umap3_trials/0.0_100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_20.npz
Binary file not shown.
Binary file added umap3_trials/0.0_20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_30.npz
Binary file not shown.
Binary file added umap3_trials/0.0_30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_40.npz
Binary file not shown.
Binary file added umap3_trials/0.0_40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_50.npz
Binary file not shown.
Binary file added umap3_trials/0.0_50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_60.npz
Binary file not shown.
Binary file added umap3_trials/0.0_60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_70.npz
Binary file not shown.
Binary file added umap3_trials/0.0_70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_80.npz
Binary file not shown.
Binary file added umap3_trials/0.0_80.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.0_90.npz
Binary file not shown.
Binary file added umap3_trials/0.0_90.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_100.npz
Binary file not shown.
Binary file added umap3_trials/0.1_100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_20.npz
Binary file not shown.
Binary file added umap3_trials/0.1_20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_30.npz
Binary file not shown.
Binary file added umap3_trials/0.1_30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_40.npz
Binary file not shown.
Binary file added umap3_trials/0.1_40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_50.npz
Binary file not shown.
Binary file added umap3_trials/0.1_50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_60.npz
Binary file not shown.
Binary file added umap3_trials/0.1_60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_70.npz
Binary file not shown.
Binary file added umap3_trials/0.1_70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_80.npz
Binary file not shown.
Binary file added umap3_trials/0.1_80.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.1_90.npz
Binary file not shown.
Binary file added umap3_trials/0.1_90.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_100.npz
Binary file not shown.
Binary file added umap3_trials/0.25_100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_20.npz
Binary file not shown.
Binary file added umap3_trials/0.25_20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_30.npz
Binary file not shown.
Binary file added umap3_trials/0.25_30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_40.npz
Binary file not shown.
Binary file added umap3_trials/0.25_40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_50.npz
Binary file not shown.
Binary file added umap3_trials/0.25_50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_60.npz
Binary file not shown.
Binary file added umap3_trials/0.25_60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_70.npz
Binary file not shown.
Binary file added umap3_trials/0.25_70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added umap3_trials/0.25_80.npz
Binary file not shown.
Binary file added umap3_trials/0.25_80.png
Binary file added umap3_trials/0.25_90.npz
Binary file not shown.
Binary file added umap3_trials/0.25_90.png
Binary file added umap3_trials/0.5_100.npz
Binary file not shown.
Binary file added umap3_trials/0.5_100.png
Binary file added umap3_trials/0.5_20.npz
Binary file not shown.
Binary file added umap3_trials/0.5_20.png
Binary file added umap3_trials/0.5_30.npz
Binary file not shown.
Binary file added umap3_trials/0.5_30.png
Binary file added umap3_trials/0.5_40.npz
Binary file not shown.
Binary file added umap3_trials/0.5_40.png
Binary file added umap3_trials/0.5_50.npz
Binary file not shown.
Binary file added umap3_trials/0.5_50.png
Binary file added umap3_trials/0.5_60.npz
Binary file not shown.
Binary file added umap3_trials/0.5_60.png
Binary file added umap3_trials/0.5_70.npz
Binary file not shown.
Binary file added umap3_trials/0.5_70.png
Binary file added umap3_trials/0.5_80.npz
Binary file not shown.
Binary file added umap3_trials/0.5_80.png
Binary file added umap3_trials/0.5_90.npz
Binary file not shown.
Binary file added umap3_trials/0.5_90.png
Binary file added umap3_trials/0.75_100.npz
Binary file not shown.
Binary file added umap3_trials/0.75_100.png
Binary file added umap3_trials/0.75_20.npz
Binary file not shown.
Binary file added umap3_trials/0.75_20.png
Binary file added umap3_trials/0.75_30.npz
Binary file not shown.
Binary file added umap3_trials/0.75_30.png
Binary file added umap3_trials/0.75_40.npz
Binary file not shown.
Binary file added umap3_trials/0.75_40.png
Binary file added umap3_trials/0.75_50.npz
Binary file not shown.
Binary file added umap3_trials/0.75_50.png
Binary file added umap3_trials/0.75_60.npz
Binary file not shown.
Binary file added umap3_trials/0.75_60.png
Binary file added umap3_trials/0.75_70.npz
Binary file not shown.
Binary file added umap3_trials/0.75_70.png
Binary file added umap3_trials/0.75_80.npz
Binary file not shown.
Binary file added umap3_trials/0.75_80.png
Binary file added umap3_trials/0.75_90.npz
Binary file not shown.
Binary file added umap3_trials/0.75_90.png
Binary file added umap3_trials/0.8_100.npz
Binary file not shown.
Binary file added umap3_trials/0.8_100.png
Binary file added umap3_trials/0.8_20.npz
Binary file not shown.
Binary file added umap3_trials/0.8_20.png
Binary file added umap3_trials/0.8_30.npz
Binary file not shown.
Binary file added umap3_trials/0.8_30.png
Binary file added umap3_trials/0.8_40.npz
Binary file not shown.
Binary file added umap3_trials/0.8_40.png
Binary file added umap3_trials/0.8_50.npz
Binary file not shown.
Binary file added umap3_trials/0.8_50.png
Binary file added umap3_trials/0.8_60.npz
Binary file not shown.
Binary file added umap3_trials/0.8_60.png
Binary file added umap3_trials/0.8_70.npz
Binary file not shown.
Binary file added umap3_trials/0.8_70.png
Binary file added umap3_trials/0.8_80.npz
Binary file not shown.
Binary file added umap3_trials/0.8_80.png
Binary file added umap3_trials/0.8_90.npz
Binary file not shown.
Binary file added umap3_trials/0.8_90.png
Binary file added umap3_trials/0.99_100.npz
Binary file not shown.
Binary file added umap3_trials/0.99_100.png
Binary file added umap3_trials/0.99_20.npz
Binary file not shown.
Binary file added umap3_trials/0.99_20.png
Binary file added umap3_trials/0.99_30.npz
Binary file not shown.
Binary file added umap3_trials/0.99_30.png
Binary file added umap3_trials/0.99_40.npz
Binary file not shown.
Binary file added umap3_trials/0.99_40.png
Binary file added umap3_trials/0.99_50.npz
Binary file not shown.
Binary file added umap3_trials/0.99_50.png
Binary file added umap3_trials/0.99_60.npz
Binary file not shown.
Binary file added umap3_trials/0.99_60.png
Binary file added umap3_trials/0.99_70.npz
Binary file not shown.
Binary file added umap3_trials/0.99_70.png
Binary file added umap3_trials/0.99_80.npz
Binary file not shown.
Binary file added umap3_trials/0.99_80.png
Binary file added umap3_trials/0.99_90.npz
Binary file not shown.
Binary file added umap3_trials/0.99_90.png
Binary file added umap3_trials/0.9_100.npz
Binary file not shown.
Binary file added umap3_trials/0.9_100.png
Binary file added umap3_trials/0.9_20.npz
Binary file not shown.
Binary file added umap3_trials/0.9_20.png
Binary file added umap3_trials/0.9_30.npz
Binary file not shown.
Binary file added umap3_trials/0.9_30.png
Binary file added umap3_trials/0.9_40.npz
Binary file not shown.
Binary file added umap3_trials/0.9_40.png
Binary file added umap3_trials/0.9_50.npz
Binary file not shown.
Binary file added umap3_trials/0.9_50.png
Binary file added umap3_trials/0.9_60.npz
Binary file not shown.
Binary file added umap3_trials/0.9_60.png
Binary file added umap3_trials/0.9_70.npz
Binary file not shown.
Binary file added umap3_trials/0.9_70.png
Binary file added umap3_trials/0.9_80.npz
Binary file not shown.
Binary file added umap3_trials/0.9_80.png
Binary file added umap3_trials/0.9_90.npz
Binary file not shown.
Binary file added umap3_trials/0.9_90.png
Binary file added umap3_trials/hm.png
Binary file added umap4_trials/0.0_100.npz
Binary file not shown.
Binary file added umap4_trials/0.0_100.png
Binary file added umap4_trials/0.0_20.npz
Binary file not shown.
Binary file added umap4_trials/0.0_20.png
Binary file added umap4_trials/0.0_30.npz
Binary file not shown.
Binary file added umap4_trials/0.0_30.png
Binary file added umap4_trials/0.0_40.npz
Binary file not shown.
Binary file added umap4_trials/0.0_40.png
Binary file added umap4_trials/0.0_50.npz
Binary file not shown.
Binary file added umap4_trials/0.0_50.png
Binary file added umap4_trials/0.0_60.npz
Binary file not shown.
Binary file added umap4_trials/0.0_60.png
Binary file added umap4_trials/0.0_70.npz
Binary file not shown.
Binary file added umap4_trials/0.0_70.png
Binary file added umap4_trials/0.0_80.npz
Binary file not shown.
Binary file added umap4_trials/0.0_80.png
Binary file added umap4_trials/0.0_90.npz
Binary file not shown.
Binary file added umap4_trials/0.0_90.png
Binary file added umap4_trials/0.1_100.npz
Binary file not shown.
Binary file added umap4_trials/0.1_100.png
Binary file added umap4_trials/0.1_20.npz
Binary file not shown.
Binary file added umap4_trials/0.1_20.png
Binary file added umap4_trials/0.1_30.npz
Binary file not shown.
Binary file added umap4_trials/0.1_30.png
Binary file added umap4_trials/0.1_40.npz
Binary file not shown.
Binary file added umap4_trials/0.1_40.png
Binary file added umap4_trials/0.1_50.npz
Binary file not shown.
Binary file added umap4_trials/0.1_50.png
Binary file added umap4_trials/0.1_60.npz
Binary file not shown.
Binary file added umap4_trials/0.1_60.png
Binary file added umap4_trials/0.1_70.npz
Binary file not shown.
Binary file added umap4_trials/0.1_70.png
Binary file added umap4_trials/0.1_80.npz
Binary file not shown.
Binary file added umap4_trials/0.1_80.png
Binary file added umap4_trials/0.1_90.npz
Binary file not shown.
Binary file added umap4_trials/0.1_90.png
Binary file added umap4_trials/0.25_100.npz
Binary file not shown.
Binary file added umap4_trials/0.25_100.png
Binary file added umap4_trials/0.25_20.npz
Binary file not shown.
Binary file added umap4_trials/0.25_20.png
Binary file added umap4_trials/0.25_30.npz
Binary file not shown.
Binary file added umap4_trials/0.25_30.png
Binary file added umap4_trials/0.25_40.npz
Binary file not shown.
Binary file added umap4_trials/0.25_40.png
Binary file added umap4_trials/0.25_50.npz
Binary file not shown.
Binary file added umap4_trials/0.25_50.png
Binary file added umap4_trials/0.25_60.npz
Binary file not shown.
Binary file added umap4_trials/0.25_60.png
Binary file added umap4_trials/0.25_70.npz
Binary file not shown.
Binary file added umap4_trials/0.25_70.png
Binary file added umap4_trials/0.25_80.npz
Binary file not shown.
Binary file added umap4_trials/0.25_80.png
Binary file added umap4_trials/0.25_90.npz
Binary file not shown.
Binary file added umap4_trials/0.25_90.png
Binary file added umap4_trials/0.5_100.npz
Binary file not shown.
Binary file added umap4_trials/0.5_100.png
Binary file added umap4_trials/0.5_20.npz
Binary file not shown.
Binary file added umap4_trials/0.5_20.png
Binary file added umap4_trials/0.5_30.npz
Binary file not shown.
Binary file added umap4_trials/0.5_30.png
Binary file added umap4_trials/0.5_40.npz
Binary file not shown.
Binary file added umap4_trials/0.5_40.png
Binary file added umap4_trials/0.5_50.npz
Binary file not shown.
Binary file added umap4_trials/0.5_50.png
Binary file added umap4_trials/0.5_60.npz
Binary file not shown.
Binary file added umap4_trials/0.5_60.png
Binary file added umap4_trials/0.5_70.npz
Binary file not shown.
Binary file added umap4_trials/0.5_70.png
Binary file added umap4_trials/0.5_80.npz
Binary file not shown.
Binary file added umap4_trials/0.5_80.png
Binary file added umap4_trials/0.5_90.npz
Binary file not shown.
Binary file added umap4_trials/0.5_90.png
Binary file added umap4_trials/0.75_100.npz
Binary file not shown.
Binary file added umap4_trials/0.75_100.png
Binary file added umap4_trials/0.75_20.npz
Binary file not shown.
Binary file added umap4_trials/0.75_20.png
Binary file added umap4_trials/0.75_30.npz
Binary file not shown.
Binary file added umap4_trials/0.75_30.png
Binary file added umap4_trials/0.75_40.npz
Binary file not shown.
Binary file added umap4_trials/0.75_40.png
Binary file added umap4_trials/0.75_50.npz
Binary file not shown.
Binary file added umap4_trials/0.75_50.png
Binary file added umap4_trials/0.75_60.npz
Binary file not shown.
Binary file added umap4_trials/0.75_60.png
Binary file added umap4_trials/0.75_70.npz
Binary file not shown.
Binary file added umap4_trials/0.75_70.png
Binary file added umap4_trials/0.75_80.npz
Binary file not shown.
Binary file added umap4_trials/0.75_80.png
Binary file added umap4_trials/0.75_90.npz
Binary file not shown.
Binary file added umap4_trials/0.75_90.png
Binary file added umap4_trials/0.8_100.npz
Binary file not shown.
Binary file added umap4_trials/0.8_100.png
Binary file added umap4_trials/0.8_20.npz
Binary file not shown.
Binary file added umap4_trials/0.8_20.png
Binary file added umap4_trials/0.8_30.npz
Binary file not shown.
Binary file added umap4_trials/0.8_30.png
Binary file added umap4_trials/0.8_40.npz
Binary file not shown.
Binary file added umap4_trials/0.8_40.png
Binary file added umap4_trials/0.8_50.npz
Binary file not shown.
Binary file added umap4_trials/0.8_50.png
Binary file added umap4_trials/0.8_60.npz
Binary file not shown.
Binary file added umap4_trials/0.8_60.png
Binary file added umap4_trials/0.8_70.npz
Binary file not shown.
Binary file added umap4_trials/0.8_70.png
Binary file added umap4_trials/0.8_80.npz
Binary file not shown.
Binary file added umap4_trials/0.8_80.png
Binary file added umap4_trials/0.8_90.npz
Binary file not shown.
Binary file added umap4_trials/0.8_90.png
Binary file added umap4_trials/0.99_100.npz
Binary file not shown.
Binary file added umap4_trials/0.99_100.png
Binary file added umap4_trials/0.99_20.npz
Binary file not shown.
Binary file added umap4_trials/0.99_20.png
Binary file added umap4_trials/0.99_30.npz
Binary file not shown.
Binary file added umap4_trials/0.99_30.png
Binary file added umap4_trials/0.99_40.npz
Binary file not shown.
Binary file added umap4_trials/0.99_40.png
Binary file added umap4_trials/0.99_50.npz
Binary file not shown.
Binary file added umap4_trials/0.99_50.png
Binary file added umap4_trials/0.99_60.npz
Binary file not shown.
Binary file added umap4_trials/0.99_60.png
Binary file added umap4_trials/0.99_70.npz
Binary file not shown.
Binary file added umap4_trials/0.99_70.png
Binary file added umap4_trials/0.99_80.npz
Binary file not shown.
Binary file added umap4_trials/0.99_80.png
Binary file added umap4_trials/0.99_90.npz
Binary file not shown.
Binary file added umap4_trials/0.99_90.png
Binary file added umap4_trials/0.9_100.npz
Binary file not shown.
Binary file added umap4_trials/0.9_100.png
Binary file added umap4_trials/0.9_20.npz
Binary file not shown.
Binary file added umap4_trials/0.9_20.png
Binary file added umap4_trials/0.9_30.npz
Binary file not shown.
Binary file added umap4_trials/0.9_30.png
Binary file added umap4_trials/0.9_40.npz
Binary file not shown.
Binary file added umap4_trials/0.9_40.png
Binary file added umap4_trials/0.9_50.npz
Binary file not shown.
Binary file added umap4_trials/0.9_50.png
Binary file added umap4_trials/0.9_60.npz
Binary file not shown.
Binary file added umap4_trials/0.9_60.png
Binary file added umap4_trials/0.9_70.npz
Binary file not shown.
Binary file added umap4_trials/0.9_70.png
Binary file added umap4_trials/0.9_80.npz
Binary file not shown.
Binary file added umap4_trials/0.9_80.png
Binary file added umap4_trials/0.9_90.npz
Binary file not shown.
Binary file added umap4_trials/0.9_90.png
Binary file added umap4_trials/hm.png
271 changes: 271 additions & 0 deletions umap_error.ipynb

Large diffs are not rendered by default.