Skip to content

Instantly share code, notes, and snippets.

View rpalo's full-sized avatar

Ryan Palo rpalo

View GitHub Profile
@rpalo
rpalo / example.yaml
Created September 25, 2019 21:01
A simplified YAML parser to see if I could do it. Also to use in a static site generator fun project. Basically a minimal viable script. Could be more fancy.
a: b
c: "d"
e: 45
f: 156.23
g: -1
h: -0.25
i:
k: l
m: n
o:
closest_indices = np.argmin(distance, axis=1)
predictions = training_labels[closest_indices]
distance = np.sqrt(np.sum((testing - training)**2, axis=1))
testing = testing.reshape((75, 4, 1))
# This is equivalent to doing:
testing = np.expand_dims(testing, axis=2)
# Or even:
testing = testing[:, :, np.newaxis]
training = training.reshape((75, 4, 1)) # Add the third axis
training = np.swapaxes(training, 0, 2) # ROTATE!
distances = np.sqrt((testing - training)**2)
training = np.swapaxes(training, 0, 1)
import numpy as np
training = np.random.randint(0, 100, 50).reshape(50, 1)
testing = np.random.randint(0, 100, 50).reshape(50, 1)
import numpy as np
a = np.array([1, 2, 3, 4, 5])
b = np.array([1, 1, 1, 5, 1])
a + b
# => [2, 3, 4, 9, 6]