{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from API import API\n", "api = API()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## General checking functions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "api.getPlaylists()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test Asaf's id\n", "Asaf = \"21hrln7z7x7afddwq263yj34q\"\n", "\n", "# For testing purposes\n", "def getPlaylistNames():\n", " playlist_names = []\n", " playlists = api.getPlaylists(Asaf)\n", " for i in range(len(playlists)):\n", " # print(playlists[i]['name'])\n", " playlist_names.append(playlists[i]['name'])\n", " return playlist_names\n", "\n", "playlist_names = getPlaylistNames()\n", "playlist_names\n", " # print(playlists[i]['uri'])\n", " # print()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "playlist_uri = api.getPlaylistIdFromName(\"Dancey\", Asaf)\n", "playlist_uri" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test adding 5 songs from my playlist to another one of Asaf's playlists (a test one)\n", "if \"Dancey_copy\" not in playlist_names:\n", " print(\"need to create this\")\n", " api.createPlaylist(\"Dancey_copy\", Asaf)\n", "\n", "playlist_names = getPlaylistNames()\n", "print(f\"Dancey_copy in playlist_names?\\n{'Dancey_copy' in playlist_names}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "new = api.generatePlaylistNames()\n", "len(new) # 45 for 2 playlists per user" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get Recommendations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check error messages" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Error test, too many seeds\n", "api.getRecommendations(seed_artists=['1', '2', '3'], seed_genres=['4'], seed_tracks=['5','6'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Error test, no seeds\n", "api.getRecommendations()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Run the thing" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "filepath /home/musashishi/Documents/DSS/dss-group-assignment/modules\n", "implicit path /home/musashishi/Documents/DSS/dss-group-assignment/implicit\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "2022-12-04 12:56:48,009 - INFO - \u001b[31m\u001b[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\u001b[0m\n", " * Running on http://127.0.0.1:5000\n", "2022-12-04 12:56:48,009 - INFO - \u001b[33mPress CTRL+C to quit\u001b[0m\n", "2022-12-04 12:56:48,009 - INFO - * Restarting with stat\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "2022-12-04 12:56:48,096 - WARNING - * Debugger is active!\n", "2022-12-04 12:56:48,096 - INFO - * Debugger PIN: 128-058-343\n", "2022-12-04 12:56:49,958 - INFO - 127.0.0.1 - - [04/Dec/2022 12:56:49] \"GET / HTTP/1.1\" 200 -\n", "2022-12-04 12:56:50,037 - INFO - 127.0.0.1 - - [04/Dec/2022 12:56:50] \"\u001b[33mGET /favicon.ico HTTP/1.1\u001b[0m\" 404 -\n", "2022-12-04 12:56:50,073 - INFO - 127.0.0.1 - - [04/Dec/2022 12:56:50] \"\u001b[32mGET /auth HTTP/1.1\u001b[0m\" 302 -\n", "2022-12-04 12:56:51,189 - INFO - 127.0.0.1 - - [04/Dec/2022 12:56:51] \"GET /callback HTTP/1.1\" 200 -\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2022-12-04 12:57:32,273 - INFO - * Detected change in '/home/musashishi/Documents/DSS/dss-group-assignment/modules/API.py', reloading\n", "2022-12-04 12:57:32,296 - INFO - * Restarting with stat\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "2022-12-04 12:57:32,380 - WARNING - * Debugger is active!\n", "2022-12-04 12:57:32,381 - INFO - * Debugger PIN: 128-058-343\n", "2022-12-04 13:06:37,788 - INFO - 127.0.0.1 - - [04/Dec/2022 13:06:37] \"GET / HTTP/1.1\" 200 -\n", "2022-12-04 13:06:37,869 - INFO - 127.0.0.1 - - [04/Dec/2022 13:06:37] \"\u001b[33mGET /favicon.ico HTTP/1.1\u001b[0m\" 404 -\n", "2022-12-04 13:06:37,892 - INFO - 127.0.0.1 - - [04/Dec/2022 13:06:37] \"\u001b[32mGET /auth HTTP/1.1\u001b[0m\" 302 -\n", "2022-12-04 13:06:39,035 - INFO - 127.0.0.1 - - [04/Dec/2022 13:06:39] \"GET /callback HTTP/1.1\" 200 -\n", "2022-12-04 13:08:42,567 - INFO - * Detected change in '/home/musashishi/Documents/DSS/dss-group-assignment/modules/API.py', reloading\n", "2022-12-04 13:08:42,595 - INFO - * Restarting with stat\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "2022-12-04 13:08:42,680 - WARNING - * Debugger is active!\n", "2022-12-04 13:08:42,680 - INFO - * Debugger PIN: 128-058-343\n", "2022-12-04 13:10:08,411 - INFO - 127.0.0.1 - - [04/Dec/2022 13:10:08] \"GET / HTTP/1.1\" 200 -\n", "2022-12-04 13:10:08,506 - INFO - 127.0.0.1 - - [04/Dec/2022 13:10:08] \"\u001b[33mGET /favicon.ico HTTP/1.1\u001b[0m\" 404 -\n", "2022-12-04 13:10:08,529 - INFO - 127.0.0.1 - - [04/Dec/2022 13:10:08] \"\u001b[32mGET /auth HTTP/1.1\u001b[0m\" 302 -\n", "2022-12-04 13:10:09,700 - INFO - 127.0.0.1 - - [04/Dec/2022 13:10:09] \"GET /callback HTTP/1.1\" 200 -\n", "2022-12-04 13:11:06,085 - INFO - * Detected change in '/home/musashishi/Documents/DSS/dss-group-assignment/modules/API.py', reloading\n", "2022-12-04 13:11:06,114 - INFO - * Restarting with stat\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "2022-12-04 13:11:06,198 - WARNING - * Debugger is active!\n", "2022-12-04 13:11:06,198 - INFO - * Debugger PIN: 128-058-343\n", "2022-12-04 13:11:13,443 - INFO - 127.0.0.1 - - [04/Dec/2022 13:11:13] \"GET / HTTP/1.1\" 200 -\n", "2022-12-04 13:11:13,515 - INFO - 127.0.0.1 - - [04/Dec/2022 13:11:13] \"\u001b[33mGET /favicon.ico HTTP/1.1\u001b[0m\" 404 -\n", "2022-12-04 13:11:13,549 - INFO - 127.0.0.1 - - [04/Dec/2022 13:11:13] \"\u001b[32mGET /auth HTTP/1.1\u001b[0m\" 302 -\n", "2022-12-04 13:11:14,602 - INFO - 127.0.0.1 - - [04/Dec/2022 13:11:14] \"GET /callback HTTP/1.1\" 200 -\n", "2022-12-04 13:13:24,498 - INFO - 127.0.0.1 - - [04/Dec/2022 13:13:24] \"GET / HTTP/1.1\" 200 -\n", "2022-12-04 13:13:24,581 - INFO - 127.0.0.1 - - [04/Dec/2022 13:13:24] \"\u001b[33mGET /favicon.ico HTTP/1.1\u001b[0m\" 404 -\n", "2022-12-04 13:13:24,608 - INFO - 127.0.0.1 - - [04/Dec/2022 13:13:24] \"\u001b[32mGET /auth HTTP/1.1\u001b[0m\" 302 -\n", "2022-12-04 13:13:39,135 - INFO - 127.0.0.1 - - [04/Dec/2022 13:13:39] \"GET / HTTP/1.1\" 200 -\n", "2022-12-04 13:13:39,201 - INFO - 127.0.0.1 - - [04/Dec/2022 13:13:39] \"\u001b[33mGET /favicon.ico HTTP/1.1\u001b[0m\" 404 -\n", "2022-12-04 13:13:39,232 - INFO - 127.0.0.1 - - [04/Dec/2022 13:13:39] \"\u001b[32mGET /auth HTTP/1.1\u001b[0m\" 302 -\n", "2022-12-04 13:13:40,216 - INFO - 127.0.0.1 - - [04/Dec/2022 13:13:40] \"GET /callback HTTP/1.1\" 200 -\n", "2022-12-04 13:13:55,778 - INFO - * Detected change in '/home/musashishi/Documents/DSS/dss-group-assignment/modules/API.py', reloading\n", "2022-12-04 13:13:55,803 - INFO - * Restarting with stat\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "2022-12-04 13:13:55,890 - WARNING - * Debugger is active!\n", "2022-12-04 13:13:55,890 - INFO - * Debugger PIN: 128-058-343\n", "2022-12-04 13:14:07,154 - INFO - 127.0.0.1 - - [04/Dec/2022 13:14:07] \"GET / HTTP/1.1\" 200 -\n", "2022-12-04 13:14:07,205 - INFO - 127.0.0.1 - - [04/Dec/2022 13:14:07] \"\u001b[33mGET /favicon.ico HTTP/1.1\u001b[0m\" 404 -\n", "2022-12-04 13:14:07,229 - INFO - 127.0.0.1 - - [04/Dec/2022 13:14:07] \"\u001b[32mGET /auth HTTP/1.1\u001b[0m\" 302 -\n", "2022-12-04 13:14:08,314 - INFO - 127.0.0.1 - - [04/Dec/2022 13:14:08] \"GET /callback HTTP/1.1\" 200 -\n", "2022-12-04 13:35:10,625 - INFO - * Detected change in '/home/musashishi/Documents/DSS/dss-group-assignment/modules/API.py', reloading\n", "2022-12-04 13:35:10,646 - INFO - * Restarting with stat\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "'FLASK_ENV' is deprecated and will not be used in Flask 2.3. Use 'FLASK_DEBUG' instead.\n", "2022-12-04 13:35:10,732 - WARNING - * Debugger is active!\n", "2022-12-04 13:35:10,733 - INFO - * Debugger PIN: 128-058-343\n" ] } ], "source": [ "import pandas as pd\n", "import sys\n", "sys.path.append(\"./modules/\")\n", "from API import API\n", "\n", "api = API()\n", "# test_user = pd.read_csv('participant data/API_test_user.csv')\n", "# seed_tracks=list(test_user.iloc[:5]['item'])\n", "# res = api.getRecommendations(seed_tracks=seed_tracks)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def convertResponseToDf(res, user_id):\n", " df = pd.DataFrame(res)\n", " df['user_id'] = user_id\n", " df.rename(columns={\"id\": \"song_id\"})\n", " df['rank'] = range(1, len(df)+1) # make it nice by starting the rank at 1 instead of 0\n", " return df" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# This has song_id, user_id, all features, rank of the song for the user\n", "# convertResponseToDf(res, list(test_user['user'])[0])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# test_user['user'].nunique() # checks out" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Df with the following columns\n", "song_id, user_id, all features, rank_of_song_for_user" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0user_idtrack_seedsgenre_seeds
00d28708a363b58062087293f779256fffa38fdd56c1f79d...2LfyBCqm9JlARHp22qWMxt,6VcRonz2dMc0xgbi5R14HF,...reggae,electronic
1112f2e84ef897c8e32d9919871acbe861b4ac4b5ef26117...6SQLk9HSNketfgs2AyIiMs,1rRwwqteLePmi70PGaC8ah,...jazz,funk
221dbfdf95b6c701b8852fd90799cc45ddba10435d8e9e15...1HNkqx9Ahdgi1Ixy2xkKkL,6Ed1q0X8oSKSm4IIhiQbYg,...classical,rnb
33ed56810fb3ca5f82385492151b3d37f9f2d21eabebef21...04colE4oJt50AHwFhrT57v,7bzaIsOrDQRomB7dzbILaD,...rockabilly,dubstep
441418fcc80d2e4febb58f44fcd93ff755df16b64edfa900...76voC75r72iKgNsmEMkDBX,15O3cEqfhnudkoMfZcJ7XV,...hard-rock,progressive-house
\n", "
" ], "text/plain": [ " Unnamed: 0 user_id \\\n", "0 0 d28708a363b58062087293f779256fffa38fdd56c1f79d... \n", "1 1 12f2e84ef897c8e32d9919871acbe861b4ac4b5ef26117... \n", "2 2 1dbfdf95b6c701b8852fd90799cc45ddba10435d8e9e15... \n", "3 3 ed56810fb3ca5f82385492151b3d37f9f2d21eabebef21... \n", "4 4 1418fcc80d2e4febb58f44fcd93ff755df16b64edfa900... \n", "\n", " track_seeds \\\n", "0 2LfyBCqm9JlARHp22qWMxt,6VcRonz2dMc0xgbi5R14HF,... \n", "1 6SQLk9HSNketfgs2AyIiMs,1rRwwqteLePmi70PGaC8ah,... \n", "2 1HNkqx9Ahdgi1Ixy2xkKkL,6Ed1q0X8oSKSm4IIhiQbYg,... \n", "3 04colE4oJt50AHwFhrT57v,7bzaIsOrDQRomB7dzbILaD,... \n", "4 76voC75r72iKgNsmEMkDBX,15O3cEqfhnudkoMfZcJ7XV,... \n", "\n", " genre_seeds \n", "0 reggae,electronic \n", "1 jazz,funk \n", "2 classical,rnb \n", "3 rockabilly,dubstep \n", "4 hard-rock,progressive-house " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "seeds_diverse = pd.read_csv('./participant data/seeds_diverse.csv')\n", "seeds_non_diverse = pd.read_csv('./participant data/seeds_non_diverse.csv')\n", "seeds_diverse.head()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0user_idtrack_seedsgenre_seeds
00d28708a363b58062087293f779256fffa38fdd56c1f79d...2LfyBCqm9JlARHp22qWMxt,6VcRonz2dMc0xgbi5R14HF,...reggae,electronic
1112f2e84ef897c8e32d9919871acbe861b4ac4b5ef26117...6SQLk9HSNketfgs2AyIiMs,1rRwwqteLePmi70PGaC8ah,...jazz,funk
221dbfdf95b6c701b8852fd90799cc45ddba10435d8e9e15...1HNkqx9Ahdgi1Ixy2xkKkL,6Ed1q0X8oSKSm4IIhiQbYg,...classical,rnb
33ed56810fb3ca5f82385492151b3d37f9f2d21eabebef21...04colE4oJt50AHwFhrT57v,7bzaIsOrDQRomB7dzbILaD,...rockabilly,dubstep
441418fcc80d2e4febb58f44fcd93ff755df16b64edfa900...76voC75r72iKgNsmEMkDBX,15O3cEqfhnudkoMfZcJ7XV,...hard-rock,progressive-house
\n", "
" ], "text/plain": [ " Unnamed: 0 user_id \\\n", "0 0 d28708a363b58062087293f779256fffa38fdd56c1f79d... \n", "1 1 12f2e84ef897c8e32d9919871acbe861b4ac4b5ef26117... \n", "2 2 1dbfdf95b6c701b8852fd90799cc45ddba10435d8e9e15... \n", "3 3 ed56810fb3ca5f82385492151b3d37f9f2d21eabebef21... \n", "4 4 1418fcc80d2e4febb58f44fcd93ff755df16b64edfa900... \n", "\n", " track_seeds \\\n", "0 2LfyBCqm9JlARHp22qWMxt,6VcRonz2dMc0xgbi5R14HF,... \n", "1 6SQLk9HSNketfgs2AyIiMs,1rRwwqteLePmi70PGaC8ah,... \n", "2 1HNkqx9Ahdgi1Ixy2xkKkL,6Ed1q0X8oSKSm4IIhiQbYg,... \n", "3 04colE4oJt50AHwFhrT57v,7bzaIsOrDQRomB7dzbILaD,... \n", "4 76voC75r72iKgNsmEMkDBX,15O3cEqfhnudkoMfZcJ7XV,... \n", "\n", " genre_seeds \n", "0 reggae,electronic \n", "1 jazz,funk \n", "2 classical,rnb \n", "3 rockabilly,dubstep \n", "4 hard-rock,progressive-house " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "seeds_diverse = seeds_diverse.fillna('')\n", "seeds_non_diverse = seeds_non_diverse.fillna('')\n", "seeds_diverse.head()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 45/45 [07:44<00:00, 10.32s/it]\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
danceabilityenergykeyloudnessmodespeechinessacousticnessinstrumentalnesslivenessvalencetempotypeiduritrack_hrefanalysis_urlduration_mstime_signatureuser_idrank
00.6580.9305-2.91200.14100.02360.0000000.57800.132104.018audio_features1RJZLVGpBG9nNZiHRQSWTpspotify:track:1RJZLVGpBG9nNZiHRQSWTphttps://api.spotify.com/v1/tracks/1RJZLVGpBG9n...https://api.spotify.com/v1/audio-analysis/1RJZ...2376804d28708a363b58062087293f779256fffa38fdd56c1f79d...1
10.3770.1826-10.89610.03030.69000.0000000.11000.324151.630audio_features3Y315h4E3Oc1rGdpr6Mxr9spotify:track:3Y315h4E3Oc1rGdpr6Mxr9https://api.spotify.com/v1/tracks/3Y315h4E3Oc1...https://api.spotify.com/v1/audio-analysis/3Y31...2459873d28708a363b58062087293f779256fffa38fdd56c1f79d...2
20.6380.4418-6.90900.02900.41500.0000790.11000.150117.933audio_features68tZwwRuo9ip5gRQFG1XWFspotify:track:68tZwwRuo9ip5gRQFG1XWFhttps://api.spotify.com/v1/tracks/68tZwwRuo9ip...https://api.spotify.com/v1/audio-analysis/68tZ...2714934d28708a363b58062087293f779256fffa38fdd56c1f79d...3
30.6960.8370-5.03400.11800.06470.0000000.11300.916153.294audio_features53a8WmHKKrxhDiBRGqDlgVspotify:track:53a8WmHKKrxhDiBRGqDlgVhttps://api.spotify.com/v1/tracks/53a8WmHKKrxh...https://api.spotify.com/v1/audio-analysis/53a8...2464534d28708a363b58062087293f779256fffa38fdd56c1f79d...4
40.4290.3459-9.72400.03710.85800.0000000.26800.317133.139audio_features1GWsEPe6pIYlqrNFEMExdXspotify:track:1GWsEPe6pIYlqrNFEMExdXhttps://api.spotify.com/v1/tracks/1GWsEPe6pIYl...https://api.spotify.com/v1/audio-analysis/1GWs...2686254d28708a363b58062087293f779256fffa38fdd56c1f79d...5
...............................................................
950.5400.5212-5.67610.03080.53800.0000000.16100.193119.828audio_features7J7bVfhuxXjpLvvp3DijiXspotify:track:7J7bVfhuxXjpLvvp3DijiXhttps://api.spotify.com/v1/tracks/7J7bVfhuxXjp...https://api.spotify.com/v1/audio-analysis/7J7b...2560004d28708a363b58062087293f779256fffa38fdd56c1f79d...96
960.8080.6207-7.22910.11500.07280.0000000.06950.921129.954audio_features4XysPaqDJfL0T6iFJuSNMospotify:track:4XysPaqDJfL0T6iFJuSNMohttps://api.spotify.com/v1/tracks/4XysPaqDJfL0...https://api.spotify.com/v1/audio-analysis/4Xys...2258534d28708a363b58062087293f779256fffa38fdd56c1f79d...97
970.5690.7851-4.05700.04570.05050.0000010.08600.303128.031audio_features0xIVvRmjztR1AwuHrkhH41spotify:track:0xIVvRmjztR1AwuHrkhH41https://api.spotify.com/v1/tracks/0xIVvRmjztR1...https://api.spotify.com/v1/audio-analysis/0xIV...1483874d28708a363b58062087293f779256fffa38fdd56c1f79d...98
980.7990.61010-6.29800.19400.30200.0000000.08240.871170.037audio_features67sEGnjlCAoDRWqNejM0XYspotify:track:67sEGnjlCAoDRWqNejM0XYhttps://api.spotify.com/v1/tracks/67sEGnjlCAoD...https://api.spotify.com/v1/audio-analysis/67sE...2072194d28708a363b58062087293f779256fffa38fdd56c1f79d...99
990.5080.6076-6.84410.02870.44200.0000000.08940.389143.505audio_features1SFVITPd1k2W6ZqZ2muaHDspotify:track:1SFVITPd1k2W6ZqZ2muaHDhttps://api.spotify.com/v1/tracks/1SFVITPd1k2W...https://api.spotify.com/v1/audio-analysis/1SFV...2826404d28708a363b58062087293f779256fffa38fdd56c1f79d...100
\n", "

100 rows × 20 columns

\n", "
" ], "text/plain": [ " danceability energy key loudness mode speechiness acousticness \\\n", "0 0.658 0.930 5 -2.912 0 0.1410 0.0236 \n", "1 0.377 0.182 6 -10.896 1 0.0303 0.6900 \n", "2 0.638 0.441 8 -6.909 0 0.0290 0.4150 \n", "3 0.696 0.837 0 -5.034 0 0.1180 0.0647 \n", "4 0.429 0.345 9 -9.724 0 0.0371 0.8580 \n", ".. ... ... ... ... ... ... ... \n", "95 0.540 0.521 2 -5.676 1 0.0308 0.5380 \n", "96 0.808 0.620 7 -7.229 1 0.1150 0.0728 \n", "97 0.569 0.785 1 -4.057 0 0.0457 0.0505 \n", "98 0.799 0.610 10 -6.298 0 0.1940 0.3020 \n", "99 0.508 0.607 6 -6.844 1 0.0287 0.4420 \n", "\n", " instrumentalness liveness valence tempo type \\\n", "0 0.000000 0.5780 0.132 104.018 audio_features \n", "1 0.000000 0.1100 0.324 151.630 audio_features \n", "2 0.000079 0.1100 0.150 117.933 audio_features \n", "3 0.000000 0.1130 0.916 153.294 audio_features \n", "4 0.000000 0.2680 0.317 133.139 audio_features \n", ".. ... ... ... ... ... \n", "95 0.000000 0.1610 0.193 119.828 audio_features \n", "96 0.000000 0.0695 0.921 129.954 audio_features \n", "97 0.000001 0.0860 0.303 128.031 audio_features \n", "98 0.000000 0.0824 0.871 170.037 audio_features \n", "99 0.000000 0.0894 0.389 143.505 audio_features \n", "\n", " id uri \\\n", "0 1RJZLVGpBG9nNZiHRQSWTp spotify:track:1RJZLVGpBG9nNZiHRQSWTp \n", "1 3Y315h4E3Oc1rGdpr6Mxr9 spotify:track:3Y315h4E3Oc1rGdpr6Mxr9 \n", "2 68tZwwRuo9ip5gRQFG1XWF spotify:track:68tZwwRuo9ip5gRQFG1XWF \n", "3 53a8WmHKKrxhDiBRGqDlgV spotify:track:53a8WmHKKrxhDiBRGqDlgV \n", "4 1GWsEPe6pIYlqrNFEMExdX spotify:track:1GWsEPe6pIYlqrNFEMExdX \n", ".. ... ... \n", "95 7J7bVfhuxXjpLvvp3DijiX spotify:track:7J7bVfhuxXjpLvvp3DijiX \n", "96 4XysPaqDJfL0T6iFJuSNMo spotify:track:4XysPaqDJfL0T6iFJuSNMo \n", "97 0xIVvRmjztR1AwuHrkhH41 spotify:track:0xIVvRmjztR1AwuHrkhH41 \n", "98 67sEGnjlCAoDRWqNejM0XY spotify:track:67sEGnjlCAoDRWqNejM0XY \n", "99 1SFVITPd1k2W6ZqZ2muaHD spotify:track:1SFVITPd1k2W6ZqZ2muaHD \n", "\n", " track_href \\\n", "0 https://api.spotify.com/v1/tracks/1RJZLVGpBG9n... \n", "1 https://api.spotify.com/v1/tracks/3Y315h4E3Oc1... \n", "2 https://api.spotify.com/v1/tracks/68tZwwRuo9ip... \n", "3 https://api.spotify.com/v1/tracks/53a8WmHKKrxh... \n", "4 https://api.spotify.com/v1/tracks/1GWsEPe6pIYl... \n", ".. ... \n", "95 https://api.spotify.com/v1/tracks/7J7bVfhuxXjp... \n", "96 https://api.spotify.com/v1/tracks/4XysPaqDJfL0... \n", "97 https://api.spotify.com/v1/tracks/0xIVvRmjztR1... \n", "98 https://api.spotify.com/v1/tracks/67sEGnjlCAoD... \n", "99 https://api.spotify.com/v1/tracks/1SFVITPd1k2W... \n", "\n", " analysis_url duration_ms \\\n", "0 https://api.spotify.com/v1/audio-analysis/1RJZ... 237680 \n", "1 https://api.spotify.com/v1/audio-analysis/3Y31... 245987 \n", "2 https://api.spotify.com/v1/audio-analysis/68tZ... 271493 \n", "3 https://api.spotify.com/v1/audio-analysis/53a8... 246453 \n", "4 https://api.spotify.com/v1/audio-analysis/1GWs... 268625 \n", ".. ... ... \n", "95 https://api.spotify.com/v1/audio-analysis/7J7b... 256000 \n", "96 https://api.spotify.com/v1/audio-analysis/4Xys... 225853 \n", "97 https://api.spotify.com/v1/audio-analysis/0xIV... 148387 \n", "98 https://api.spotify.com/v1/audio-analysis/67sE... 207219 \n", "99 https://api.spotify.com/v1/audio-analysis/1SFV... 282640 \n", "\n", " time_signature user_id rank \n", "0 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 1 \n", "1 3 d28708a363b58062087293f779256fffa38fdd56c1f79d... 2 \n", "2 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 3 \n", "3 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 4 \n", "4 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 5 \n", ".. ... ... ... \n", "95 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 96 \n", "96 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 97 \n", "97 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 98 \n", "98 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 99 \n", "99 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 100 \n", "\n", "[100 rows x 20 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from tqdm import tqdm\n", "diverse_recs = []\n", "for index, row in tqdm(seeds_diverse.iterrows(), total= len(seeds_diverse)):\n", " recs = api.getRecommendations(seed_tracks=row['track_seeds'], seed_genres=row['genre_seeds'], limit=100)\n", " if recs != 'Error':\n", " diverse_recs.append(convertResponseToDf(recs, row['user_id']))\n", "diverse_recs[0]" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 45/45 [07:37<00:00, 10.17s/it]\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
danceabilityenergykeyloudnessmodespeechinessacousticnessinstrumentalnesslivenessvalencetempotypeiduritrack_hrefanalysis_urlduration_mstime_signatureuser_idrank
00.3760.8095-3.90510.16800.033900.0965000.68800.147121.887audio_features3ZbmDl4M9O587VmD9IqyIjspotify:track:3ZbmDl4M9O587VmD9IqyIjhttps://api.spotify.com/v1/tracks/3ZbmDl4M9O58...https://api.spotify.com/v1/audio-analysis/3Zbm...2690404d28708a363b58062087293f779256fffa38fdd56c1f79d...1
10.7250.3948-7.12010.16400.114000.0000000.07940.39981.176audio_features7FA2oxGAfveiECwzeUqOjaspotify:track:7FA2oxGAfveiECwzeUqOjahttps://api.spotify.com/v1/tracks/7FA2oxGAfvei...https://api.spotify.com/v1/audio-analysis/7FA2...2157204d28708a363b58062087293f779256fffa38fdd56c1f79d...2
20.4380.8948-4.24700.10800.003000.0000000.29900.212126.958audio_features3eunKmoXb7y9D5xmbGbfW5spotify:track:3eunKmoXb7y9D5xmbGbfW5https://api.spotify.com/v1/tracks/3eunKmoXb7y9...https://api.spotify.com/v1/audio-analysis/3eun...1620404d28708a363b58062087293f779256fffa38fdd56c1f79d...3
30.7150.35011-13.84610.12100.046900.0000000.07240.75281.682audio_features0j2hYbbYeadrfJgII5bheaspotify:track:0j2hYbbYeadrfJgII5bheahttps://api.spotify.com/v1/tracks/0j2hYbbYeadr...https://api.spotify.com/v1/audio-analysis/0j2h...2133604d28708a363b58062087293f779256fffa38fdd56c1f79d...4
40.7660.4274-10.95900.33600.731000.0005720.18400.82374.063audio_features2p6WDr28CJXYNglfrneMLLspotify:track:2p6WDr28CJXYNglfrneMLLhttps://api.spotify.com/v1/tracks/2p6WDr28CJXY...https://api.spotify.com/v1/audio-analysis/2p6W...2062004d28708a363b58062087293f779256fffa38fdd56c1f79d...5
...............................................................
950.4210.80610-4.10410.16200.066500.0000000.09660.400102.031audio_features2dVPrA2SRVlDqgSjTgCMiJspotify:track:2dVPrA2SRVlDqgSjTgCMiJhttps://api.spotify.com/v1/tracks/2dVPrA2SRVlD...https://api.spotify.com/v1/audio-analysis/2dVP...1624004d28708a363b58062087293f779256fffa38fdd56c1f79d...96
960.7140.4807-6.64300.26800.025900.0000000.09120.75675.875audio_features5zqqkvoeXhgab0ALShNeynspotify:track:5zqqkvoeXhgab0ALShNeynhttps://api.spotify.com/v1/tracks/5zqqkvoeXhga...https://api.spotify.com/v1/audio-analysis/5zqq...2339734d28708a363b58062087293f779256fffa38fdd56c1f79d...97
970.4990.8269-7.08200.05340.000950.0290000.12200.427140.007audio_features5OJ8hNTKYU2dCvdgnOarLUspotify:track:5OJ8hNTKYU2dCvdgnOarLUhttps://api.spotify.com/v1/tracks/5OJ8hNTKYU2d...https://api.spotify.com/v1/audio-analysis/5OJ8...2810834d28708a363b58062087293f779256fffa38fdd56c1f79d...98
980.7030.7771-4.76010.14300.031500.0000660.04850.586160.112audio_features2rK7knZC1komGjPscuEXV5spotify:track:2rK7knZC1komGjPscuEXV5https://api.spotify.com/v1/tracks/2rK7knZC1kom...https://api.spotify.com/v1/audio-analysis/2rK7...3199204d28708a363b58062087293f779256fffa38fdd56c1f79d...99
990.6940.7510-5.34410.03020.045900.0000130.14600.479130.010audio_features00Hht4IVIdQUSxJBf4BK9Uspotify:track:00Hht4IVIdQUSxJBf4BK9Uhttps://api.spotify.com/v1/tracks/00Hht4IVIdQU...https://api.spotify.com/v1/audio-analysis/00Hh...2453444d28708a363b58062087293f779256fffa38fdd56c1f79d...100
\n", "

100 rows × 20 columns

\n", "
" ], "text/plain": [ " danceability energy key loudness mode speechiness acousticness \\\n", "0 0.376 0.809 5 -3.905 1 0.1680 0.03390 \n", "1 0.725 0.394 8 -7.120 1 0.1640 0.11400 \n", "2 0.438 0.894 8 -4.247 0 0.1080 0.00300 \n", "3 0.715 0.350 11 -13.846 1 0.1210 0.04690 \n", "4 0.766 0.427 4 -10.959 0 0.3360 0.73100 \n", ".. ... ... ... ... ... ... ... \n", "95 0.421 0.806 10 -4.104 1 0.1620 0.06650 \n", "96 0.714 0.480 7 -6.643 0 0.2680 0.02590 \n", "97 0.499 0.826 9 -7.082 0 0.0534 0.00095 \n", "98 0.703 0.777 1 -4.760 1 0.1430 0.03150 \n", "99 0.694 0.751 0 -5.344 1 0.0302 0.04590 \n", "\n", " instrumentalness liveness valence tempo type \\\n", "0 0.096500 0.6880 0.147 121.887 audio_features \n", "1 0.000000 0.0794 0.399 81.176 audio_features \n", "2 0.000000 0.2990 0.212 126.958 audio_features \n", "3 0.000000 0.0724 0.752 81.682 audio_features \n", "4 0.000572 0.1840 0.823 74.063 audio_features \n", ".. ... ... ... ... ... \n", "95 0.000000 0.0966 0.400 102.031 audio_features \n", "96 0.000000 0.0912 0.756 75.875 audio_features \n", "97 0.029000 0.1220 0.427 140.007 audio_features \n", "98 0.000066 0.0485 0.586 160.112 audio_features \n", "99 0.000013 0.1460 0.479 130.010 audio_features \n", "\n", " id uri \\\n", "0 3ZbmDl4M9O587VmD9IqyIj spotify:track:3ZbmDl4M9O587VmD9IqyIj \n", "1 7FA2oxGAfveiECwzeUqOja spotify:track:7FA2oxGAfveiECwzeUqOja \n", "2 3eunKmoXb7y9D5xmbGbfW5 spotify:track:3eunKmoXb7y9D5xmbGbfW5 \n", "3 0j2hYbbYeadrfJgII5bhea spotify:track:0j2hYbbYeadrfJgII5bhea \n", "4 2p6WDr28CJXYNglfrneMLL spotify:track:2p6WDr28CJXYNglfrneMLL \n", ".. ... ... \n", "95 2dVPrA2SRVlDqgSjTgCMiJ spotify:track:2dVPrA2SRVlDqgSjTgCMiJ \n", "96 5zqqkvoeXhgab0ALShNeyn spotify:track:5zqqkvoeXhgab0ALShNeyn \n", "97 5OJ8hNTKYU2dCvdgnOarLU spotify:track:5OJ8hNTKYU2dCvdgnOarLU \n", "98 2rK7knZC1komGjPscuEXV5 spotify:track:2rK7knZC1komGjPscuEXV5 \n", "99 00Hht4IVIdQUSxJBf4BK9U spotify:track:00Hht4IVIdQUSxJBf4BK9U \n", "\n", " track_href \\\n", "0 https://api.spotify.com/v1/tracks/3ZbmDl4M9O58... \n", "1 https://api.spotify.com/v1/tracks/7FA2oxGAfvei... \n", "2 https://api.spotify.com/v1/tracks/3eunKmoXb7y9... \n", "3 https://api.spotify.com/v1/tracks/0j2hYbbYeadr... \n", "4 https://api.spotify.com/v1/tracks/2p6WDr28CJXY... \n", ".. ... \n", "95 https://api.spotify.com/v1/tracks/2dVPrA2SRVlD... \n", "96 https://api.spotify.com/v1/tracks/5zqqkvoeXhga... \n", "97 https://api.spotify.com/v1/tracks/5OJ8hNTKYU2d... \n", "98 https://api.spotify.com/v1/tracks/2rK7knZC1kom... \n", "99 https://api.spotify.com/v1/tracks/00Hht4IVIdQU... \n", "\n", " analysis_url duration_ms \\\n", "0 https://api.spotify.com/v1/audio-analysis/3Zbm... 269040 \n", "1 https://api.spotify.com/v1/audio-analysis/7FA2... 215720 \n", "2 https://api.spotify.com/v1/audio-analysis/3eun... 162040 \n", "3 https://api.spotify.com/v1/audio-analysis/0j2h... 213360 \n", "4 https://api.spotify.com/v1/audio-analysis/2p6W... 206200 \n", ".. ... ... \n", "95 https://api.spotify.com/v1/audio-analysis/2dVP... 162400 \n", "96 https://api.spotify.com/v1/audio-analysis/5zqq... 233973 \n", "97 https://api.spotify.com/v1/audio-analysis/5OJ8... 281083 \n", "98 https://api.spotify.com/v1/audio-analysis/2rK7... 319920 \n", "99 https://api.spotify.com/v1/audio-analysis/00Hh... 245344 \n", "\n", " time_signature user_id rank \n", "0 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 1 \n", "1 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 2 \n", "2 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 3 \n", "3 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 4 \n", "4 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 5 \n", ".. ... ... ... \n", "95 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 96 \n", "96 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 97 \n", "97 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 98 \n", "98 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 99 \n", "99 4 d28708a363b58062087293f779256fffa38fdd56c1f79d... 100 \n", "\n", "[100 rows x 20 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# TODO handle 0 seeds\n", "from tqdm import tqdm\n", "non_diverse_recs = []\n", "for index, row in tqdm(seeds_non_diverse.iterrows(), total= len(seeds_non_diverse)):\n", " recs = api.getRecommendations(seed_tracks=row['track_seeds'], seed_genres=row['genre_seeds'], limit=100)\n", " if recs != 'Error':\n", " non_diverse_recs.append(convertResponseToDf(recs, row['user_id']))\n", "non_diverse_recs[0]" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "45\n", "45\n" ] } ], "source": [ "print(len(diverse_recs))\n", "print(len(non_diverse_recs))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "# Save it all!\n", "diverse_df = pd.concat(diverse_recs)\n", "non_diverse_df = pd.concat(non_diverse_recs)\n", "\n", "diverse_df.to_csv('participant data/recommendations_diverse.csv')\n", "non_diverse_df.to_csv('participant data/recommendations_non_diverse.csv')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# genres = api.getAvailableGenres()\n", "# genres = genres['genres']\n", "# genres" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.6 ('venv': venv)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "a5f6721cff687d3080de9329c3bd8bdd11a992611b372cba762cc6d8bb8ccdc5" } } }, "nbformat": 4, "nbformat_minor": 2 }