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
### Adding big DataFrames in Pandas | |
pandas_df + pandas_df + pandas_df + pandas_df + pandas_df | |
### Adding big DataFrames in Dask | |
dask_df + dask_df + dask_df + dask_df + dask_df |
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
### Filtering by price in Pandas | |
pandas_df[pandas_df["price"] > 250] | |
### Filtering by price in Dask | |
dask_df[dask_df["price"] > 250] |
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
### Calculate mean using pandas | |
pandas_df["price"].mean() | |
### Calculate mean using Dask | |
dask_df["price"].mean() |
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 dask.dataframe as dd | |
import pandas as pd | |
dask_df = dd.read_csv("stock_data.csv") | |
dask_df = dask_df.repartition(partition_size="100MB") | |
pandas_df = pd.read_csv("stock_data.csv") |
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 random | |
import pandas as pd | |
NUM_ROWS = 1000000 | |
symbols = ["AAPL", "GOOG", "AMZN", "NFLX", "MSFT"] | |
prices = [random.randint(1, 500) for _ in range(50)] | |
def generate_random_stock_data(symbols, prices): | |
return {"symbol": random.sample(symbols, 1)[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
test_loss, test_accuracy = model.evaluate(test_images, test_labels, verbose=2) | |
print('\nTest accuracy = {0:.2f}%'.format(test_accuracy*100.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
plt.plot(history.history['accuracy'], label='accuracy') | |
plt.plot(history.history['val_accuracy'], label='val_accuracy') | |
plt.xlabel('Epoch') | |
plt.ylabel('Accuracy') | |
plt.ylim([0.7, 1]) | |
plt.legend(loc='best') | |
plt.plot(history.history['loss'], label='loss') | |
plt.plot(history.history['val_loss'], label='val_loss') | |
plt.xlabel('Epoch') |
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
adam = optimizers.Adam(lr=0.0001) | |
model.compile(adam, loss='categorical_crossentropy', metrics=["accuracy"]) | |
history = model.fit(train_images, train_labels, epochs=10, | |
validation_data=(test_images, test_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
train_images = train_images.reshape(60000, 28, 28, 1).astype('float32') / 255.0 | |
test_images = test_images.reshape(10000, 28, 28, 1).astype('float32') / 255.0 | |
train_labels = tf.keras.utils.to_categorical(train_labels, 10) | |
test_labels = tf.keras.utils.to_categorical(test_labels, 10) |
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
IMG_SIZE = (28, 28, 1) | |
input_img = layers.Input(shape=IMG_SIZE) | |
model = layers.Conv2D(32, (3, 3), padding='same')(input_img) | |
model = layers.Activation('relu')(model) | |
model = layers.Conv2D(32, (3, 3), padding='same', strides=(2, 2))(model) | |
model = layers.Activation('relu')(model) | |
model = layers.Conv2D(64, (3, 3), padding='same')(model) | |
model = layers.Activation('relu')(model) |