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
df_party.boxplot(vert = False, figsize = (13,7), showfliers = False, showmeans = True, | |
patch_artist=True, boxprops=dict(linestyle='-', linewidth=1.5), | |
flierprops=dict(linestyle='-', linewidth=1.5), | |
medianprops=dict(linestyle='-', linewidth=1.5), | |
whiskerprops=dict(linestyle='-', linewidth=1.5), | |
capprops=dict(linestyle='-', linewidth=1.5)) | |
plt.title("Original Playlist's Box Plot", fontsize=16, fontweight='heavy') | |
plt.show() |
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
df_dinner = fetch_audio_features(sp, username, '37SqXO5bm81JmGCiuhin0L') | |
df_party = fetch_audio_features(sp, username, '2m75Xwwn4YqhwsxHH7Qc9W') | |
df_lounge = fetch_audio_features(sp, username, '6Jbi3Y7ZNNgSrPaZF4DpUp') | |
df_pop = fetch_audio_features(sp, username, '3u2nUYNuI08yUg877JE5FI') |
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
# Take a sample from the Pop playlist | |
df_pop_sample_I = df_pop.sample(n=40, weights='danceability', random_state=1) | |
df_pop_sample_I.describe() | |
# Concatenate the original playlist with the sample | |
df_party_exp_I = pd.concat([df_party, df_pop_sample_I]) | |
df_party_exp_I.describe() |
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
# Take a sample from the Pop playlist | |
df_pop_sample_II = df_pop[(df_pop['danceability'] > 69.55) & (df_pop['valence'] > 51.89)].copy() | |
# Concatenate the original playlist with the sample | |
df_party_exp_II = pd.concat([df_party, df_pop_sample_II]) | |
df_party_exp_II.describe() |
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
# Take a sample from the Pop playlist | |
df_pop_sample_III = df_pop[df_pop['score'] > df_party['score'].mean()].copy() | |
# Concatenate the original playlist with the sample | |
df_party_exp_III = pd.concat([df_party, df_pop_sample_III]) | |
df_party_exp_III.describe() |
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
# Make a temporary list of tracks | |
list_track = df_party_exp_III.index | |
# Create the playlist | |
enrich_playlist(sp, username, '779Uv1K6LcYiiWxblSDjx7', list_track) |
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
# Read in data | |
spam_collection = pd.read_csv('SMSSpamCollection', sep='\t', header=None, names=['Label', 'SMS']) | |
# Randomize the data set | |
randomized_collection = spam_collection.sample(frac=1, random_state=3) | |
# Calculate index for the split-up | |
training_test_index = round(len(randomized_collection) * 0.8) | |
# Training/Test split-up |
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 libraries | |
import numpy as np | |
import pandas as pd | |
import re | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
from sklearn.cluster import KMeans | |
from kneed import KneeLocator | |
from sklearn.linear_model import LogisticRegression |
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
### While in Python environment ### | |
import nltk | |
# Download stopwords | |
nltk.download(‘stopwords’) | |
# Download punkt sentence tokenizer | |
nltk.download(‘punkt’) | |
# Download wordnet |
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
# Install Requests | |
pip3 install requests | |
# Install Kneed | |
pip install kneed |