-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatlas.py
More file actions
19 lines (17 loc) · 782 Bytes
/
Copy pathatlas.py
File metadata and controls
19 lines (17 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from nomic import atlas
import json
import numpy as np
from sklearn.decomposition import PCA
def updateAtlas():
with open('vectorsWithMetadata.json') as f:
data = json.load(f)
embeddings = np.array([data[key]['values'] for key in data])
pca = PCA(n_components=2048)
reduced_embeddings = pca.fit_transform(embeddings)
project = atlas.map_data(embeddings=reduced_embeddings, data=([{"title" : data[key]["title"],"url": "https://xkcd.com/" + data[key]["id"], "date" : data[key]["date"]} for key in data]), identifier="xkcd")
projectID = project.id
mapID = project.get_map(name="xkcd").id
mapURL = f"https://atlas.nomic.ai/map/{projectID}/{mapID}"
with open("data/mapURL.txt", "w") as f:
f.write(mapURL)
print("updated map")