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
with ProgressBar(): | |
print(nyc_data_raw.drop('total_amount', axis=1).head()) |
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
... | |
# load all datasets | |
(azData, azLabels) = load_az_dataset(args["az"]) | |
(digitsData, digitsLabels) = load_zero_nine_dataset() | |
# the MNIST dataset occupies the labels 0-9, so let's add 10 to every A-Z label to ensure the A-Z characters are not incorrectly labeled as digits | |
azLabels += 10 | |
# stack the A-Z data and labels with the MNIST digits data and labels | |
data = np.vstack([azData, digitsData]) |
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
def load_zero_nine_dataset(): | |
# load the MNIST dataset and stack the training data and testing | |
# data together (we'll create our own training and testing splits | |
# later in the project) | |
((trainData, trainLabels), (testData, testLabels)) = mnist.load_data() | |
data = np.vstack([trainData, testData]) | |
labels = np.hstack([trainLabels, testLabels]) | |
# return a 2-tuple of the MNIST data and labels | |
return (data, labels) |
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
def load_az_dataset(dataset_path): | |
# initialize the list of data and labels | |
data = [] | |
labels = [] | |
# loop over the rows of the A-Z handwritten digit dataset | |
for row in open(dataset_path): | |
# parse the label and image from the row | |
row = row.split(",") | |
label = int(row[0]) |
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
# TensorFlow and tf.keras | |
import tensorflow as tf | |
from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions | |
from tensorflow.keras.preprocessing import image | |
# Helper libraries | |
import numpy as np | |
import matplotlib.pyplot as plt |
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
/* | |
* s, d, e represents three pegs (source, destination and extra). | |
* n is number of discs (All initially in s) | |
*/ | |
resolver_tower_of_hanoi = function (s, d, e, n) { | |
// terminating condition | |
if (n <= 0) { | |
return |
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
look_for_key = function(box) { | |
for (item in box) { | |
if (item.is_a_key()) { | |
print("found the key") | |
} else { | |
look_for_key(item) | |
} | |
} | |
} |
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
// ✗ avoid | |
function animal () { ... } | |
// ✓ ok | |
function Animal () { ... } |
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
// ✓ ok | |
if (flag) { | |
// ... | |
} else { | |
// ... | |
} |
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
// ✗ avoid | |
if (obj.prop) { .. } | |
if (obj.prop !== undefined) { ... } | |
// ✓ ok | |
if (Object.prototype.hasOwnProperty.call(obj, 'prop')) { ... } |
NewerOlder