Skip to content

Instantly share code, notes, and snippets.

@bmschmidt
Created March 26, 2024 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmschmidt/1391849cb0fb5b035943ddb3ba20e880 to your computer and use it in GitHub Desktop.
Save bmschmidt/1391849cb0fb5b035943ddb3ba20e880 to your computer and use it in GitHub Desktop.
# Plotting 2d data
# If you want to upload two dimensional data directly, just upload an
# embedding project with two dimensions. Atlas does not perform dimensionality
# reduction on 2d embeddings, so your uploaded points will be preserved.
# Clifford attractor function simplified from https://examples.holoviz.org/gallery/attractors/attractors.html
import numpy as np, pandas as pd
from math import sin, cos
from nomic.atlas import map_data
n=100_000
def Clifford(x, y, a, b, c, d, *o):
return sin(a * y) + c * cos(a * x), \
sin(b * x) + d * cos(b * y)
def trajectory_coords(fn, x0, y0, a, b=0, c=0, d=0, e=0, f=0, n=n):
x, y = np.zeros(n), np.zeros(n)
x[0], y[0] = x0, y0
for i in np.arange(n-1):
x[i+1], y[i+1] = fn(x[i], y[i], a, b, c, d, e, f)
return x,y
def trajectory(fn, x0, y0, a, b=0, c=0, d=0, e=0, f=0, n=n):
x, y = trajectory_coords(fn, x0, y0, a, b, c, d, e, f, n)
return np.stack([x, y], axis=1)
path = trajectory(Clifford, 0, 0, -1.3, -1.3, -1.8, -1.9)
base = path[:-2]
combined = pd.DataFrame({
'base.x': path[:-2,0],
'base.y': path[:-2,1],
'next.x': path[1:-1,0],
'next.y': path[1:-1,1],
'last.x': path[2:,0],
'last.y': path[2:,1],
})
map_data(data=combined, embeddings=base, identifier="bmschmidt/clifford", description="Clifford Attractor", topic_model=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment