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
Häxor are a rare species fruktade by the common folk for their use of mäktiga magic. However, häxorna are often missförstådda. | |
häxor: Witches | |
fruktade: feared | |
mäktiga: powerful/mighty | |
missförstådda: misunderstood |
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
Genre | Difficulty | Artist | Song | Year | |
---|---|---|---|---|---|
Pop | Easy | ABBA | Money Money Money | 1976 | |
Pop | Medium | Ariana Grande | Break Up With Your Girlfriend | 2019 | |
Metal | Hard | Slayer | Angel of Death | 1986 | |
Metal | Very Hard | Amon Amarth | The Pursuit of Vikings | 2004 |
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
from tensorflow import keras | |
from keras import Sequential | |
from keras.layers import Conv2D, MaxPool2D, BatchNormalization, Flatten, Dense, Dropout, GRU, Reshape | |
model = Sequential(name="gtzan_crnn") | |
# Convolutional Block 1 | |
model.add(Conv2D(filters=16, kernel_size=(3,3), input_shape=X_train.shape[1:])) # X_train holds the processed training spectrograms | |
model.add(MaxPool2D(pool_size=(2,2))) | |
model.add(BatchNormalization()) |
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
{ | |
"project_folders": { | |
"base_folder": "my_path/gtzan/", | |
"raw_mp3_folder": "raw_mp3s/" | |
}, | |
"build_dataset_params":{ | |
"audio_slicing_params":{ | |
"sliced_mp3_folder": "processed_mp3s/", |
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 recommend(track_id, ref_df, sp, n_recs = 5): | |
# Crawl valence and arousal of given track from spotify api | |
track_features = sp.track_audio_features(track_id) | |
track_moodvec = np.array([track_features.valence, track_features.energy]) | |
# Compute distances to all reference tracks | |
ref_df["distances"] = ref_df["mood_vec"].apply(lambda x: norm(track_moodvec-np.array(x))) | |
# Sort distances from lowest to highest | |
ref_df_sorted = ref_df.sort_values(by = "distances", ascending = True) |
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
################# | |
## PREPARATION ## | |
################# | |
# Import modules | |
import sys | |
# If your authentification script is not in the project directory | |
# append its folder to sys.path | |
sys.path.append("../spotify_api_web_app") | |
import authorization |
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
ax.text(quant_5-.1, 0.17, "5th", size = 10, alpha = 0.8) | |
ax.text(quant_25-.13, 0.27, "25th", size = 11, alpha = 0.85) | |
ax.text(quant_50-.13, 0.37, "50th", size = 12, alpha = 1) | |
ax.text(quant_75-.13, 0.47, "75th", size = 11, alpha = 0.85) | |
ax.text(quant_95-.25, 0.57, "95th Percentile", size = 10, alpha =.8) |
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 percentiles | |
quant_5, quant_25, quant_50, quant_75, quant_95 = avocado.quantile(0.05), avocado.quantile(0.25), avocado.quantile(0.5), avocado.quantile(0.75), avocado.quantile(0.95) | |
# [quantile, opacity, length] | |
quants = [[quant_5, 0.6, 0.16], [quant_25, 0.8, 0.26], [quant_50, 1, 0.36], [quant_75, 0.8, 0.46], [quant_95, 0.6, 0.56]] | |
# Plot the lines with a loop | |
for i in quants: | |
ax.axvline(i[0], alpha = i[1], ymax = i[2], linestyle = ":") |
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
fig, ax = plt.subplots(figsize = (6,4)) | |
# Plots # | |
# Plot histogram | |
avocado.plot(kind = "hist", density = True, bins = 15) # change density to true, because KDE uses density | |
# Plot KDE | |
avocado.plot(kind = "kde") | |
# X # | |
ax.set_xlabel("Average Price ($)") |
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
fig, ax = plt.subplots(figsize = (6,4)) | |
# Plots # | |
# Plot histogram | |
avocado.plot(kind = "hist", density = True, bins = 15) # change density to true, because KDE uses density | |
# Plot KDE | |
avocado.plot(kind = "kde") | |
# X # | |
ax.set_xlabel("Average Price ($)") |
NewerOlder