This file contains hidden or 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
music |
This file contains hidden or 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
progress |
This file contains hidden or 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
year to date workouts |
This file contains hidden or 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
Progress running |
This file contains hidden or 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
# Make preds on a series of random images | |
import os | |
import random | |
plt.figure(figsize=(20, 14)) | |
for i in range(3): | |
# Choose a random image from a random class | |
class_name = random.choice(class_names) | |
filename = random.choice(os.listdir(test_dir + "/" + class_name)) | |
filepath = test_dir + class_name + "/" + filename |
This file contains hidden or 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
# Plot a confusion matrix with all 3600 predictions, ground truth labels and 6 classes | |
make_confusion_matrix(y_true=y_labels, | |
y_pred=pred_classes, | |
classes=class_names_test, | |
figsize=(100, 100), | |
text_size=30, | |
norm=False, | |
savefig=True) |
This file contains hidden or 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
# Get accuracy score by comparing predicted classes to ground truth labels | |
from sklearn.metrics import accuracy_score | |
sklearn_accuracy = accuracy_score(y_labels, pred_classes) | |
sklearn_accuracy |
This file contains hidden or 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
# 1. Create base model with tf.keras.applications | |
base_model = tf.keras.applications.EfficientNetB0(include_top=False) | |
# 2. Freeze the base model (so the pre-learned patterns remain) | |
base_model.trainable = False | |
# 3. Create inputs into the base model | |
inputs = tf.keras.layers.Input(shape=(224, 224, 3), name="input_layer") | |
# 4. If using ResNet50V2, add this to speed up convergence, remove for EfficientNet |
This file contains hidden or 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
# Dataset split | |
train_dir = "/content/zw4p9kj6nt-2/data_splitting/Train/" | |
valid_dir ="/content/zw4p9kj6nt-2/data_splitting/Pred/" | |
test_dir = "/content/zw4p9kj6nt-2/data_splitting/Test/" | |
# Create data inputs | |
IMG_SIZE = (224, 224) # define image size | |
train_data = tf.keras.preprocessing.image_dataset_from_directory(directory=train_dir, | |
image_size=IMG_SIZE, | |
label_mode="categorical", # what type are the labels? | |
batch_size=32) # batch_size is 32 by default, this is generally a good number |
This file contains hidden or 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
from pandas.plotting import parallel_coordinates | |
# Plot | |
plt.figure(figsize=(12,9), dpi= 80) | |
data.drop(['Date','Holiday', 'Functioning Day'],axis=1,inplace=True) | |
parallel_coordinates(data, 'Seasons', colormap='Dark2') | |
# Lighten borders | |
plt.gca().spines["top"].set_alpha(0) | |
plt.gca().spines["bottom"].set_alpha(.3) |
NewerOlder