Skip to content

Instantly share code, notes, and snippets.

View makispl's full-sized avatar

Plegas Gerasimos makispl

View GitHub Profile
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()
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')
# 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()
# 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()
# 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()
# Make a temporary list of tracks
list_track = df_party_exp_III.index
# Create the playlist
enrich_playlist(sp, username, '779Uv1K6LcYiiWxblSDjx7', list_track)
# 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
@makispl
makispl / import.py
Last active February 23, 2021 00:08
# 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
### While in Python environment ###
import nltk
# Download stopwords
nltk.download(‘stopwords’)
# Download punkt sentence tokenizer
nltk.download(‘punkt’)
# Download wordnet
@makispl
makispl / install.py
Last active February 23, 2021 00:07
# Install Requests
pip3 install requests
# Install Kneed
pip install kneed