This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a: b | |
c: "d" | |
e: 45 | |
f: 156.23 | |
g: -1 | |
h: -0.25 | |
i: | |
k: l | |
m: n | |
o: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
closest_indices = np.argmin(distance, axis=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
predictions = training_labels[closest_indices] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
distance = np.sqrt(np.sum((testing - training)**2, axis=1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testing = testing.reshape((75, 4, 1)) | |
# This is equivalent to doing: | |
testing = np.expand_dims(testing, axis=2) | |
# Or even: | |
testing = testing[:, :, np.newaxis] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
training = training.reshape((75, 4, 1)) # Add the third axis | |
training = np.swapaxes(training, 0, 2) # ROTATE! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
distances = np.sqrt((testing - training)**2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
training = np.swapaxes(training, 0, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
training = np.random.randint(0, 100, 50).reshape(50, 1) | |
testing = np.random.randint(0, 100, 50).reshape(50, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
NewerOlder