Commit
·
f17df96
0
Parent(s):
Initial commit
Browse files- .gitignore +5 -0
- Data Cleaning.ipynb +1564 -0
- Exploratory Data Analysis.ipynb +0 -0
- Model Building.ipynb +0 -0
- README.md +79 -0
- cleaned_dataset.csv +0 -0
- dataset.csv +0 -0
.gitignore
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.txt
|
2 |
+
.venv/
|
3 |
+
.ipynb_checkpoints/
|
4 |
+
catboost_info/
|
5 |
+
my_study.db
|
Data Cleaning.ipynb
ADDED
@@ -0,0 +1,1564 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"id": "1de28f74",
|
6 |
+
"metadata": {},
|
7 |
+
"source": [
|
8 |
+
"# Data Cleaning"
|
9 |
+
]
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"cell_type": "code",
|
13 |
+
"execution_count": 1,
|
14 |
+
"id": "bc4c415f",
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [],
|
17 |
+
"source": [
|
18 |
+
"import pandas as pd\n",
|
19 |
+
"import numpy as np"
|
20 |
+
]
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"cell_type": "code",
|
24 |
+
"execution_count": 2,
|
25 |
+
"id": "6455bf8f",
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [],
|
28 |
+
"source": [
|
29 |
+
"df = pd.read_csv('dataset.csv')\n"
|
30 |
+
]
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"cell_type": "code",
|
34 |
+
"execution_count": 3,
|
35 |
+
"id": "1c2440e4",
|
36 |
+
"metadata": {},
|
37 |
+
"outputs": [
|
38 |
+
{
|
39 |
+
"name": "stdout",
|
40 |
+
"output_type": "stream",
|
41 |
+
"text": [
|
42 |
+
"Index(['Unnamed: 0', 'track_id', 'artists', 'album_name', 'track_name',\n",
|
43 |
+
" 'popularity', 'duration_ms', 'explicit', 'danceability', 'energy',\n",
|
44 |
+
" 'key', 'loudness', 'mode', 'speechiness', 'acousticness',\n",
|
45 |
+
" 'instrumentalness', 'liveness', 'valence', 'tempo', 'time_signature',\n",
|
46 |
+
" 'track_genre'],\n",
|
47 |
+
" dtype='object')\n"
|
48 |
+
]
|
49 |
+
},
|
50 |
+
{
|
51 |
+
"data": {
|
52 |
+
"text/html": [
|
53 |
+
"<div>\n",
|
54 |
+
"<style scoped>\n",
|
55 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
56 |
+
" vertical-align: middle;\n",
|
57 |
+
" }\n",
|
58 |
+
"\n",
|
59 |
+
" .dataframe tbody tr th {\n",
|
60 |
+
" vertical-align: top;\n",
|
61 |
+
" }\n",
|
62 |
+
"\n",
|
63 |
+
" .dataframe thead th {\n",
|
64 |
+
" text-align: right;\n",
|
65 |
+
" }\n",
|
66 |
+
"</style>\n",
|
67 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
68 |
+
" <thead>\n",
|
69 |
+
" <tr style=\"text-align: right;\">\n",
|
70 |
+
" <th></th>\n",
|
71 |
+
" <th>Unnamed: 0</th>\n",
|
72 |
+
" <th>track_id</th>\n",
|
73 |
+
" <th>artists</th>\n",
|
74 |
+
" <th>album_name</th>\n",
|
75 |
+
" <th>track_name</th>\n",
|
76 |
+
" <th>popularity</th>\n",
|
77 |
+
" <th>duration_ms</th>\n",
|
78 |
+
" <th>explicit</th>\n",
|
79 |
+
" <th>danceability</th>\n",
|
80 |
+
" <th>energy</th>\n",
|
81 |
+
" <th>...</th>\n",
|
82 |
+
" <th>loudness</th>\n",
|
83 |
+
" <th>mode</th>\n",
|
84 |
+
" <th>speechiness</th>\n",
|
85 |
+
" <th>acousticness</th>\n",
|
86 |
+
" <th>instrumentalness</th>\n",
|
87 |
+
" <th>liveness</th>\n",
|
88 |
+
" <th>valence</th>\n",
|
89 |
+
" <th>tempo</th>\n",
|
90 |
+
" <th>time_signature</th>\n",
|
91 |
+
" <th>track_genre</th>\n",
|
92 |
+
" </tr>\n",
|
93 |
+
" </thead>\n",
|
94 |
+
" <tbody>\n",
|
95 |
+
" <tr>\n",
|
96 |
+
" <th>0</th>\n",
|
97 |
+
" <td>0</td>\n",
|
98 |
+
" <td>5SuOikwiRyPMVoIQDJUgSV</td>\n",
|
99 |
+
" <td>Gen Hoshino</td>\n",
|
100 |
+
" <td>Comedy</td>\n",
|
101 |
+
" <td>Comedy</td>\n",
|
102 |
+
" <td>73</td>\n",
|
103 |
+
" <td>230666</td>\n",
|
104 |
+
" <td>False</td>\n",
|
105 |
+
" <td>0.676</td>\n",
|
106 |
+
" <td>0.4610</td>\n",
|
107 |
+
" <td>...</td>\n",
|
108 |
+
" <td>-6.746</td>\n",
|
109 |
+
" <td>0</td>\n",
|
110 |
+
" <td>0.1430</td>\n",
|
111 |
+
" <td>0.0322</td>\n",
|
112 |
+
" <td>0.000001</td>\n",
|
113 |
+
" <td>0.3580</td>\n",
|
114 |
+
" <td>0.715</td>\n",
|
115 |
+
" <td>87.917</td>\n",
|
116 |
+
" <td>4</td>\n",
|
117 |
+
" <td>acoustic</td>\n",
|
118 |
+
" </tr>\n",
|
119 |
+
" <tr>\n",
|
120 |
+
" <th>1</th>\n",
|
121 |
+
" <td>1</td>\n",
|
122 |
+
" <td>4qPNDBW1i3p13qLCt0Ki3A</td>\n",
|
123 |
+
" <td>Ben Woodward</td>\n",
|
124 |
+
" <td>Ghost (Acoustic)</td>\n",
|
125 |
+
" <td>Ghost - Acoustic</td>\n",
|
126 |
+
" <td>55</td>\n",
|
127 |
+
" <td>149610</td>\n",
|
128 |
+
" <td>False</td>\n",
|
129 |
+
" <td>0.420</td>\n",
|
130 |
+
" <td>0.1660</td>\n",
|
131 |
+
" <td>...</td>\n",
|
132 |
+
" <td>-17.235</td>\n",
|
133 |
+
" <td>1</td>\n",
|
134 |
+
" <td>0.0763</td>\n",
|
135 |
+
" <td>0.9240</td>\n",
|
136 |
+
" <td>0.000006</td>\n",
|
137 |
+
" <td>0.1010</td>\n",
|
138 |
+
" <td>0.267</td>\n",
|
139 |
+
" <td>77.489</td>\n",
|
140 |
+
" <td>4</td>\n",
|
141 |
+
" <td>acoustic</td>\n",
|
142 |
+
" </tr>\n",
|
143 |
+
" <tr>\n",
|
144 |
+
" <th>2</th>\n",
|
145 |
+
" <td>2</td>\n",
|
146 |
+
" <td>1iJBSr7s7jYXzM8EGcbK5b</td>\n",
|
147 |
+
" <td>Ingrid Michaelson;ZAYN</td>\n",
|
148 |
+
" <td>To Begin Again</td>\n",
|
149 |
+
" <td>To Begin Again</td>\n",
|
150 |
+
" <td>57</td>\n",
|
151 |
+
" <td>210826</td>\n",
|
152 |
+
" <td>False</td>\n",
|
153 |
+
" <td>0.438</td>\n",
|
154 |
+
" <td>0.3590</td>\n",
|
155 |
+
" <td>...</td>\n",
|
156 |
+
" <td>-9.734</td>\n",
|
157 |
+
" <td>1</td>\n",
|
158 |
+
" <td>0.0557</td>\n",
|
159 |
+
" <td>0.2100</td>\n",
|
160 |
+
" <td>0.000000</td>\n",
|
161 |
+
" <td>0.1170</td>\n",
|
162 |
+
" <td>0.120</td>\n",
|
163 |
+
" <td>76.332</td>\n",
|
164 |
+
" <td>4</td>\n",
|
165 |
+
" <td>acoustic</td>\n",
|
166 |
+
" </tr>\n",
|
167 |
+
" <tr>\n",
|
168 |
+
" <th>3</th>\n",
|
169 |
+
" <td>3</td>\n",
|
170 |
+
" <td>6lfxq3CG4xtTiEg7opyCyx</td>\n",
|
171 |
+
" <td>Kina Grannis</td>\n",
|
172 |
+
" <td>Crazy Rich Asians (Original Motion Picture Sou...</td>\n",
|
173 |
+
" <td>Can't Help Falling In Love</td>\n",
|
174 |
+
" <td>71</td>\n",
|
175 |
+
" <td>201933</td>\n",
|
176 |
+
" <td>False</td>\n",
|
177 |
+
" <td>0.266</td>\n",
|
178 |
+
" <td>0.0596</td>\n",
|
179 |
+
" <td>...</td>\n",
|
180 |
+
" <td>-18.515</td>\n",
|
181 |
+
" <td>1</td>\n",
|
182 |
+
" <td>0.0363</td>\n",
|
183 |
+
" <td>0.9050</td>\n",
|
184 |
+
" <td>0.000071</td>\n",
|
185 |
+
" <td>0.1320</td>\n",
|
186 |
+
" <td>0.143</td>\n",
|
187 |
+
" <td>181.740</td>\n",
|
188 |
+
" <td>3</td>\n",
|
189 |
+
" <td>acoustic</td>\n",
|
190 |
+
" </tr>\n",
|
191 |
+
" <tr>\n",
|
192 |
+
" <th>4</th>\n",
|
193 |
+
" <td>4</td>\n",
|
194 |
+
" <td>5vjLSffimiIP26QG5WcN2K</td>\n",
|
195 |
+
" <td>Chord Overstreet</td>\n",
|
196 |
+
" <td>Hold On</td>\n",
|
197 |
+
" <td>Hold On</td>\n",
|
198 |
+
" <td>82</td>\n",
|
199 |
+
" <td>198853</td>\n",
|
200 |
+
" <td>False</td>\n",
|
201 |
+
" <td>0.618</td>\n",
|
202 |
+
" <td>0.4430</td>\n",
|
203 |
+
" <td>...</td>\n",
|
204 |
+
" <td>-9.681</td>\n",
|
205 |
+
" <td>1</td>\n",
|
206 |
+
" <td>0.0526</td>\n",
|
207 |
+
" <td>0.4690</td>\n",
|
208 |
+
" <td>0.000000</td>\n",
|
209 |
+
" <td>0.0829</td>\n",
|
210 |
+
" <td>0.167</td>\n",
|
211 |
+
" <td>119.949</td>\n",
|
212 |
+
" <td>4</td>\n",
|
213 |
+
" <td>acoustic</td>\n",
|
214 |
+
" </tr>\n",
|
215 |
+
" </tbody>\n",
|
216 |
+
"</table>\n",
|
217 |
+
"<p>5 rows × 21 columns</p>\n",
|
218 |
+
"</div>"
|
219 |
+
],
|
220 |
+
"text/plain": [
|
221 |
+
" Unnamed: 0 track_id artists \\\n",
|
222 |
+
"0 0 5SuOikwiRyPMVoIQDJUgSV Gen Hoshino \n",
|
223 |
+
"1 1 4qPNDBW1i3p13qLCt0Ki3A Ben Woodward \n",
|
224 |
+
"2 2 1iJBSr7s7jYXzM8EGcbK5b Ingrid Michaelson;ZAYN \n",
|
225 |
+
"3 3 6lfxq3CG4xtTiEg7opyCyx Kina Grannis \n",
|
226 |
+
"4 4 5vjLSffimiIP26QG5WcN2K Chord Overstreet \n",
|
227 |
+
"\n",
|
228 |
+
" album_name \\\n",
|
229 |
+
"0 Comedy \n",
|
230 |
+
"1 Ghost (Acoustic) \n",
|
231 |
+
"2 To Begin Again \n",
|
232 |
+
"3 Crazy Rich Asians (Original Motion Picture Sou... \n",
|
233 |
+
"4 Hold On \n",
|
234 |
+
"\n",
|
235 |
+
" track_name popularity duration_ms explicit \\\n",
|
236 |
+
"0 Comedy 73 230666 False \n",
|
237 |
+
"1 Ghost - Acoustic 55 149610 False \n",
|
238 |
+
"2 To Begin Again 57 210826 False \n",
|
239 |
+
"3 Can't Help Falling In Love 71 201933 False \n",
|
240 |
+
"4 Hold On 82 198853 False \n",
|
241 |
+
"\n",
|
242 |
+
" danceability energy ... loudness mode speechiness acousticness \\\n",
|
243 |
+
"0 0.676 0.4610 ... -6.746 0 0.1430 0.0322 \n",
|
244 |
+
"1 0.420 0.1660 ... -17.235 1 0.0763 0.9240 \n",
|
245 |
+
"2 0.438 0.3590 ... -9.734 1 0.0557 0.2100 \n",
|
246 |
+
"3 0.266 0.0596 ... -18.515 1 0.0363 0.9050 \n",
|
247 |
+
"4 0.618 0.4430 ... -9.681 1 0.0526 0.4690 \n",
|
248 |
+
"\n",
|
249 |
+
" instrumentalness liveness valence tempo time_signature track_genre \n",
|
250 |
+
"0 0.000001 0.3580 0.715 87.917 4 acoustic \n",
|
251 |
+
"1 0.000006 0.1010 0.267 77.489 4 acoustic \n",
|
252 |
+
"2 0.000000 0.1170 0.120 76.332 4 acoustic \n",
|
253 |
+
"3 0.000071 0.1320 0.143 181.740 3 acoustic \n",
|
254 |
+
"4 0.000000 0.0829 0.167 119.949 4 acoustic \n",
|
255 |
+
"\n",
|
256 |
+
"[5 rows x 21 columns]"
|
257 |
+
]
|
258 |
+
},
|
259 |
+
"execution_count": 3,
|
260 |
+
"metadata": {},
|
261 |
+
"output_type": "execute_result"
|
262 |
+
}
|
263 |
+
],
|
264 |
+
"source": [
|
265 |
+
"print(df.columns)\n",
|
266 |
+
"df.head()"
|
267 |
+
]
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"attachments": {},
|
271 |
+
"cell_type": "markdown",
|
272 |
+
"id": "f1a88b42",
|
273 |
+
"metadata": {},
|
274 |
+
"source": [
|
275 |
+
"### Remove unique columns"
|
276 |
+
]
|
277 |
+
},
|
278 |
+
{
|
279 |
+
"cell_type": "code",
|
280 |
+
"execution_count": 4,
|
281 |
+
"id": "ece13796",
|
282 |
+
"metadata": {},
|
283 |
+
"outputs": [],
|
284 |
+
"source": [
|
285 |
+
"df = df.drop(['Unnamed: 0','track_id', 'album_name'],axis=1)"
|
286 |
+
]
|
287 |
+
},
|
288 |
+
{
|
289 |
+
"cell_type": "code",
|
290 |
+
"execution_count": 5,
|
291 |
+
"id": "060fbd33",
|
292 |
+
"metadata": {
|
293 |
+
"scrolled": false
|
294 |
+
},
|
295 |
+
"outputs": [
|
296 |
+
{
|
297 |
+
"data": {
|
298 |
+
"text/html": [
|
299 |
+
"<div>\n",
|
300 |
+
"<style scoped>\n",
|
301 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
302 |
+
" vertical-align: middle;\n",
|
303 |
+
" }\n",
|
304 |
+
"\n",
|
305 |
+
" .dataframe tbody tr th {\n",
|
306 |
+
" vertical-align: top;\n",
|
307 |
+
" }\n",
|
308 |
+
"\n",
|
309 |
+
" .dataframe thead th {\n",
|
310 |
+
" text-align: right;\n",
|
311 |
+
" }\n",
|
312 |
+
"</style>\n",
|
313 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
314 |
+
" <thead>\n",
|
315 |
+
" <tr style=\"text-align: right;\">\n",
|
316 |
+
" <th></th>\n",
|
317 |
+
" <th>artists</th>\n",
|
318 |
+
" <th>track_name</th>\n",
|
319 |
+
" <th>popularity</th>\n",
|
320 |
+
" <th>duration_ms</th>\n",
|
321 |
+
" <th>explicit</th>\n",
|
322 |
+
" <th>danceability</th>\n",
|
323 |
+
" <th>energy</th>\n",
|
324 |
+
" <th>key</th>\n",
|
325 |
+
" <th>loudness</th>\n",
|
326 |
+
" <th>mode</th>\n",
|
327 |
+
" <th>speechiness</th>\n",
|
328 |
+
" <th>acousticness</th>\n",
|
329 |
+
" <th>instrumentalness</th>\n",
|
330 |
+
" <th>liveness</th>\n",
|
331 |
+
" <th>valence</th>\n",
|
332 |
+
" <th>tempo</th>\n",
|
333 |
+
" <th>time_signature</th>\n",
|
334 |
+
" <th>track_genre</th>\n",
|
335 |
+
" </tr>\n",
|
336 |
+
" </thead>\n",
|
337 |
+
" <tbody>\n",
|
338 |
+
" <tr>\n",
|
339 |
+
" <th>0</th>\n",
|
340 |
+
" <td>Gen Hoshino</td>\n",
|
341 |
+
" <td>Comedy</td>\n",
|
342 |
+
" <td>73</td>\n",
|
343 |
+
" <td>230666</td>\n",
|
344 |
+
" <td>False</td>\n",
|
345 |
+
" <td>0.676</td>\n",
|
346 |
+
" <td>0.4610</td>\n",
|
347 |
+
" <td>1</td>\n",
|
348 |
+
" <td>-6.746</td>\n",
|
349 |
+
" <td>0</td>\n",
|
350 |
+
" <td>0.1430</td>\n",
|
351 |
+
" <td>0.0322</td>\n",
|
352 |
+
" <td>0.000001</td>\n",
|
353 |
+
" <td>0.3580</td>\n",
|
354 |
+
" <td>0.7150</td>\n",
|
355 |
+
" <td>87.917</td>\n",
|
356 |
+
" <td>4</td>\n",
|
357 |
+
" <td>acoustic</td>\n",
|
358 |
+
" </tr>\n",
|
359 |
+
" <tr>\n",
|
360 |
+
" <th>1</th>\n",
|
361 |
+
" <td>Ben Woodward</td>\n",
|
362 |
+
" <td>Ghost - Acoustic</td>\n",
|
363 |
+
" <td>55</td>\n",
|
364 |
+
" <td>149610</td>\n",
|
365 |
+
" <td>False</td>\n",
|
366 |
+
" <td>0.420</td>\n",
|
367 |
+
" <td>0.1660</td>\n",
|
368 |
+
" <td>1</td>\n",
|
369 |
+
" <td>-17.235</td>\n",
|
370 |
+
" <td>1</td>\n",
|
371 |
+
" <td>0.0763</td>\n",
|
372 |
+
" <td>0.9240</td>\n",
|
373 |
+
" <td>0.000006</td>\n",
|
374 |
+
" <td>0.1010</td>\n",
|
375 |
+
" <td>0.2670</td>\n",
|
376 |
+
" <td>77.489</td>\n",
|
377 |
+
" <td>4</td>\n",
|
378 |
+
" <td>acoustic</td>\n",
|
379 |
+
" </tr>\n",
|
380 |
+
" <tr>\n",
|
381 |
+
" <th>2</th>\n",
|
382 |
+
" <td>Ingrid Michaelson;ZAYN</td>\n",
|
383 |
+
" <td>To Begin Again</td>\n",
|
384 |
+
" <td>57</td>\n",
|
385 |
+
" <td>210826</td>\n",
|
386 |
+
" <td>False</td>\n",
|
387 |
+
" <td>0.438</td>\n",
|
388 |
+
" <td>0.3590</td>\n",
|
389 |
+
" <td>0</td>\n",
|
390 |
+
" <td>-9.734</td>\n",
|
391 |
+
" <td>1</td>\n",
|
392 |
+
" <td>0.0557</td>\n",
|
393 |
+
" <td>0.2100</td>\n",
|
394 |
+
" <td>0.000000</td>\n",
|
395 |
+
" <td>0.1170</td>\n",
|
396 |
+
" <td>0.1200</td>\n",
|
397 |
+
" <td>76.332</td>\n",
|
398 |
+
" <td>4</td>\n",
|
399 |
+
" <td>acoustic</td>\n",
|
400 |
+
" </tr>\n",
|
401 |
+
" <tr>\n",
|
402 |
+
" <th>3</th>\n",
|
403 |
+
" <td>Kina Grannis</td>\n",
|
404 |
+
" <td>Can't Help Falling In Love</td>\n",
|
405 |
+
" <td>71</td>\n",
|
406 |
+
" <td>201933</td>\n",
|
407 |
+
" <td>False</td>\n",
|
408 |
+
" <td>0.266</td>\n",
|
409 |
+
" <td>0.0596</td>\n",
|
410 |
+
" <td>0</td>\n",
|
411 |
+
" <td>-18.515</td>\n",
|
412 |
+
" <td>1</td>\n",
|
413 |
+
" <td>0.0363</td>\n",
|
414 |
+
" <td>0.9050</td>\n",
|
415 |
+
" <td>0.000071</td>\n",
|
416 |
+
" <td>0.1320</td>\n",
|
417 |
+
" <td>0.1430</td>\n",
|
418 |
+
" <td>181.740</td>\n",
|
419 |
+
" <td>3</td>\n",
|
420 |
+
" <td>acoustic</td>\n",
|
421 |
+
" </tr>\n",
|
422 |
+
" <tr>\n",
|
423 |
+
" <th>4</th>\n",
|
424 |
+
" <td>Chord Overstreet</td>\n",
|
425 |
+
" <td>Hold On</td>\n",
|
426 |
+
" <td>82</td>\n",
|
427 |
+
" <td>198853</td>\n",
|
428 |
+
" <td>False</td>\n",
|
429 |
+
" <td>0.618</td>\n",
|
430 |
+
" <td>0.4430</td>\n",
|
431 |
+
" <td>2</td>\n",
|
432 |
+
" <td>-9.681</td>\n",
|
433 |
+
" <td>1</td>\n",
|
434 |
+
" <td>0.0526</td>\n",
|
435 |
+
" <td>0.4690</td>\n",
|
436 |
+
" <td>0.000000</td>\n",
|
437 |
+
" <td>0.0829</td>\n",
|
438 |
+
" <td>0.1670</td>\n",
|
439 |
+
" <td>119.949</td>\n",
|
440 |
+
" <td>4</td>\n",
|
441 |
+
" <td>acoustic</td>\n",
|
442 |
+
" </tr>\n",
|
443 |
+
" <tr>\n",
|
444 |
+
" <th>5</th>\n",
|
445 |
+
" <td>Tyrone Wells</td>\n",
|
446 |
+
" <td>Days I Will Remember</td>\n",
|
447 |
+
" <td>58</td>\n",
|
448 |
+
" <td>214240</td>\n",
|
449 |
+
" <td>False</td>\n",
|
450 |
+
" <td>0.688</td>\n",
|
451 |
+
" <td>0.4810</td>\n",
|
452 |
+
" <td>6</td>\n",
|
453 |
+
" <td>-8.807</td>\n",
|
454 |
+
" <td>1</td>\n",
|
455 |
+
" <td>0.1050</td>\n",
|
456 |
+
" <td>0.2890</td>\n",
|
457 |
+
" <td>0.000000</td>\n",
|
458 |
+
" <td>0.1890</td>\n",
|
459 |
+
" <td>0.6660</td>\n",
|
460 |
+
" <td>98.017</td>\n",
|
461 |
+
" <td>4</td>\n",
|
462 |
+
" <td>acoustic</td>\n",
|
463 |
+
" </tr>\n",
|
464 |
+
" <tr>\n",
|
465 |
+
" <th>6</th>\n",
|
466 |
+
" <td>A Great Big World;Christina Aguilera</td>\n",
|
467 |
+
" <td>Say Something</td>\n",
|
468 |
+
" <td>74</td>\n",
|
469 |
+
" <td>229400</td>\n",
|
470 |
+
" <td>False</td>\n",
|
471 |
+
" <td>0.407</td>\n",
|
472 |
+
" <td>0.1470</td>\n",
|
473 |
+
" <td>2</td>\n",
|
474 |
+
" <td>-8.822</td>\n",
|
475 |
+
" <td>1</td>\n",
|
476 |
+
" <td>0.0355</td>\n",
|
477 |
+
" <td>0.8570</td>\n",
|
478 |
+
" <td>0.000003</td>\n",
|
479 |
+
" <td>0.0913</td>\n",
|
480 |
+
" <td>0.0765</td>\n",
|
481 |
+
" <td>141.284</td>\n",
|
482 |
+
" <td>3</td>\n",
|
483 |
+
" <td>acoustic</td>\n",
|
484 |
+
" </tr>\n",
|
485 |
+
" <tr>\n",
|
486 |
+
" <th>7</th>\n",
|
487 |
+
" <td>Jason Mraz</td>\n",
|
488 |
+
" <td>I'm Yours</td>\n",
|
489 |
+
" <td>80</td>\n",
|
490 |
+
" <td>242946</td>\n",
|
491 |
+
" <td>False</td>\n",
|
492 |
+
" <td>0.703</td>\n",
|
493 |
+
" <td>0.4440</td>\n",
|
494 |
+
" <td>11</td>\n",
|
495 |
+
" <td>-9.331</td>\n",
|
496 |
+
" <td>1</td>\n",
|
497 |
+
" <td>0.0417</td>\n",
|
498 |
+
" <td>0.5590</td>\n",
|
499 |
+
" <td>0.000000</td>\n",
|
500 |
+
" <td>0.0973</td>\n",
|
501 |
+
" <td>0.7120</td>\n",
|
502 |
+
" <td>150.960</td>\n",
|
503 |
+
" <td>4</td>\n",
|
504 |
+
" <td>acoustic</td>\n",
|
505 |
+
" </tr>\n",
|
506 |
+
" <tr>\n",
|
507 |
+
" <th>8</th>\n",
|
508 |
+
" <td>Jason Mraz;Colbie Caillat</td>\n",
|
509 |
+
" <td>Lucky</td>\n",
|
510 |
+
" <td>74</td>\n",
|
511 |
+
" <td>189613</td>\n",
|
512 |
+
" <td>False</td>\n",
|
513 |
+
" <td>0.625</td>\n",
|
514 |
+
" <td>0.4140</td>\n",
|
515 |
+
" <td>0</td>\n",
|
516 |
+
" <td>-8.700</td>\n",
|
517 |
+
" <td>1</td>\n",
|
518 |
+
" <td>0.0369</td>\n",
|
519 |
+
" <td>0.2940</td>\n",
|
520 |
+
" <td>0.000000</td>\n",
|
521 |
+
" <td>0.1510</td>\n",
|
522 |
+
" <td>0.6690</td>\n",
|
523 |
+
" <td>130.088</td>\n",
|
524 |
+
" <td>4</td>\n",
|
525 |
+
" <td>acoustic</td>\n",
|
526 |
+
" </tr>\n",
|
527 |
+
" <tr>\n",
|
528 |
+
" <th>9</th>\n",
|
529 |
+
" <td>Ross Copperman</td>\n",
|
530 |
+
" <td>Hunger</td>\n",
|
531 |
+
" <td>56</td>\n",
|
532 |
+
" <td>205594</td>\n",
|
533 |
+
" <td>False</td>\n",
|
534 |
+
" <td>0.442</td>\n",
|
535 |
+
" <td>0.6320</td>\n",
|
536 |
+
" <td>1</td>\n",
|
537 |
+
" <td>-6.770</td>\n",
|
538 |
+
" <td>1</td>\n",
|
539 |
+
" <td>0.0295</td>\n",
|
540 |
+
" <td>0.4260</td>\n",
|
541 |
+
" <td>0.004190</td>\n",
|
542 |
+
" <td>0.0735</td>\n",
|
543 |
+
" <td>0.1960</td>\n",
|
544 |
+
" <td>78.899</td>\n",
|
545 |
+
" <td>4</td>\n",
|
546 |
+
" <td>acoustic</td>\n",
|
547 |
+
" </tr>\n",
|
548 |
+
" </tbody>\n",
|
549 |
+
"</table>\n",
|
550 |
+
"</div>"
|
551 |
+
],
|
552 |
+
"text/plain": [
|
553 |
+
" artists track_name \\\n",
|
554 |
+
"0 Gen Hoshino Comedy \n",
|
555 |
+
"1 Ben Woodward Ghost - Acoustic \n",
|
556 |
+
"2 Ingrid Michaelson;ZAYN To Begin Again \n",
|
557 |
+
"3 Kina Grannis Can't Help Falling In Love \n",
|
558 |
+
"4 Chord Overstreet Hold On \n",
|
559 |
+
"5 Tyrone Wells Days I Will Remember \n",
|
560 |
+
"6 A Great Big World;Christina Aguilera Say Something \n",
|
561 |
+
"7 Jason Mraz I'm Yours \n",
|
562 |
+
"8 Jason Mraz;Colbie Caillat Lucky \n",
|
563 |
+
"9 Ross Copperman Hunger \n",
|
564 |
+
"\n",
|
565 |
+
" popularity duration_ms explicit danceability energy key loudness \\\n",
|
566 |
+
"0 73 230666 False 0.676 0.4610 1 -6.746 \n",
|
567 |
+
"1 55 149610 False 0.420 0.1660 1 -17.235 \n",
|
568 |
+
"2 57 210826 False 0.438 0.3590 0 -9.734 \n",
|
569 |
+
"3 71 201933 False 0.266 0.0596 0 -18.515 \n",
|
570 |
+
"4 82 198853 False 0.618 0.4430 2 -9.681 \n",
|
571 |
+
"5 58 214240 False 0.688 0.4810 6 -8.807 \n",
|
572 |
+
"6 74 229400 False 0.407 0.1470 2 -8.822 \n",
|
573 |
+
"7 80 242946 False 0.703 0.4440 11 -9.331 \n",
|
574 |
+
"8 74 189613 False 0.625 0.4140 0 -8.700 \n",
|
575 |
+
"9 56 205594 False 0.442 0.6320 1 -6.770 \n",
|
576 |
+
"\n",
|
577 |
+
" mode speechiness acousticness instrumentalness liveness valence \\\n",
|
578 |
+
"0 0 0.1430 0.0322 0.000001 0.3580 0.7150 \n",
|
579 |
+
"1 1 0.0763 0.9240 0.000006 0.1010 0.2670 \n",
|
580 |
+
"2 1 0.0557 0.2100 0.000000 0.1170 0.1200 \n",
|
581 |
+
"3 1 0.0363 0.9050 0.000071 0.1320 0.1430 \n",
|
582 |
+
"4 1 0.0526 0.4690 0.000000 0.0829 0.1670 \n",
|
583 |
+
"5 1 0.1050 0.2890 0.000000 0.1890 0.6660 \n",
|
584 |
+
"6 1 0.0355 0.8570 0.000003 0.0913 0.0765 \n",
|
585 |
+
"7 1 0.0417 0.5590 0.000000 0.0973 0.7120 \n",
|
586 |
+
"8 1 0.0369 0.2940 0.000000 0.1510 0.6690 \n",
|
587 |
+
"9 1 0.0295 0.4260 0.004190 0.0735 0.1960 \n",
|
588 |
+
"\n",
|
589 |
+
" tempo time_signature track_genre \n",
|
590 |
+
"0 87.917 4 acoustic \n",
|
591 |
+
"1 77.489 4 acoustic \n",
|
592 |
+
"2 76.332 4 acoustic \n",
|
593 |
+
"3 181.740 3 acoustic \n",
|
594 |
+
"4 119.949 4 acoustic \n",
|
595 |
+
"5 98.017 4 acoustic \n",
|
596 |
+
"6 141.284 3 acoustic \n",
|
597 |
+
"7 150.960 4 acoustic \n",
|
598 |
+
"8 130.088 4 acoustic \n",
|
599 |
+
"9 78.899 4 acoustic "
|
600 |
+
]
|
601 |
+
},
|
602 |
+
"execution_count": 5,
|
603 |
+
"metadata": {},
|
604 |
+
"output_type": "execute_result"
|
605 |
+
}
|
606 |
+
],
|
607 |
+
"source": [
|
608 |
+
"df.head(10)"
|
609 |
+
]
|
610 |
+
},
|
611 |
+
{
|
612 |
+
"cell_type": "code",
|
613 |
+
"execution_count": 6,
|
614 |
+
"id": "d801195c",
|
615 |
+
"metadata": {},
|
616 |
+
"outputs": [
|
617 |
+
{
|
618 |
+
"data": {
|
619 |
+
"text/plain": [
|
620 |
+
"artists object\n",
|
621 |
+
"track_name object\n",
|
622 |
+
"popularity int64\n",
|
623 |
+
"duration_ms int64\n",
|
624 |
+
"explicit bool\n",
|
625 |
+
"danceability float64\n",
|
626 |
+
"energy float64\n",
|
627 |
+
"key int64\n",
|
628 |
+
"loudness float64\n",
|
629 |
+
"mode int64\n",
|
630 |
+
"speechiness float64\n",
|
631 |
+
"acousticness float64\n",
|
632 |
+
"instrumentalness float64\n",
|
633 |
+
"liveness float64\n",
|
634 |
+
"valence float64\n",
|
635 |
+
"tempo float64\n",
|
636 |
+
"time_signature int64\n",
|
637 |
+
"track_genre object\n",
|
638 |
+
"dtype: object"
|
639 |
+
]
|
640 |
+
},
|
641 |
+
"execution_count": 6,
|
642 |
+
"metadata": {},
|
643 |
+
"output_type": "execute_result"
|
644 |
+
}
|
645 |
+
],
|
646 |
+
"source": [
|
647 |
+
"df.dtypes"
|
648 |
+
]
|
649 |
+
},
|
650 |
+
{
|
651 |
+
"attachments": {},
|
652 |
+
"cell_type": "markdown",
|
653 |
+
"id": "aeb25f1a",
|
654 |
+
"metadata": {},
|
655 |
+
"source": [
|
656 |
+
"### Drop Null Values"
|
657 |
+
]
|
658 |
+
},
|
659 |
+
{
|
660 |
+
"cell_type": "code",
|
661 |
+
"execution_count": 7,
|
662 |
+
"id": "ce3c3319",
|
663 |
+
"metadata": {},
|
664 |
+
"outputs": [
|
665 |
+
{
|
666 |
+
"name": "stdout",
|
667 |
+
"output_type": "stream",
|
668 |
+
"text": [
|
669 |
+
"artists 1\n",
|
670 |
+
"track_name 1\n",
|
671 |
+
"popularity 0\n",
|
672 |
+
"duration_ms 0\n",
|
673 |
+
"explicit 0\n",
|
674 |
+
"danceability 0\n",
|
675 |
+
"energy 0\n",
|
676 |
+
"key 0\n",
|
677 |
+
"loudness 0\n",
|
678 |
+
"mode 0\n",
|
679 |
+
"speechiness 0\n",
|
680 |
+
"acousticness 0\n",
|
681 |
+
"instrumentalness 0\n",
|
682 |
+
"liveness 0\n",
|
683 |
+
"valence 0\n",
|
684 |
+
"tempo 0\n",
|
685 |
+
"time_signature 0\n",
|
686 |
+
"track_genre 0\n",
|
687 |
+
"dtype: int64\n"
|
688 |
+
]
|
689 |
+
}
|
690 |
+
],
|
691 |
+
"source": [
|
692 |
+
"print(df.isna().sum())\n",
|
693 |
+
"df=df.dropna()"
|
694 |
+
]
|
695 |
+
},
|
696 |
+
{
|
697 |
+
"attachments": {},
|
698 |
+
"cell_type": "markdown",
|
699 |
+
"id": "de7960de",
|
700 |
+
"metadata": {},
|
701 |
+
"source": [
|
702 |
+
"### Drop Duplicated Rows (Same artists and track_name)"
|
703 |
+
]
|
704 |
+
},
|
705 |
+
{
|
706 |
+
"cell_type": "code",
|
707 |
+
"execution_count": 8,
|
708 |
+
"id": "eb46cc03",
|
709 |
+
"metadata": {},
|
710 |
+
"outputs": [
|
711 |
+
{
|
712 |
+
"data": {
|
713 |
+
"text/html": [
|
714 |
+
"<div>\n",
|
715 |
+
"<style scoped>\n",
|
716 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
717 |
+
" vertical-align: middle;\n",
|
718 |
+
" }\n",
|
719 |
+
"\n",
|
720 |
+
" .dataframe tbody tr th {\n",
|
721 |
+
" vertical-align: top;\n",
|
722 |
+
" }\n",
|
723 |
+
"\n",
|
724 |
+
" .dataframe thead th {\n",
|
725 |
+
" text-align: right;\n",
|
726 |
+
" }\n",
|
727 |
+
"</style>\n",
|
728 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
729 |
+
" <thead>\n",
|
730 |
+
" <tr style=\"text-align: right;\">\n",
|
731 |
+
" <th></th>\n",
|
732 |
+
" <th>artists</th>\n",
|
733 |
+
" <th>track_name</th>\n",
|
734 |
+
" <th>popularity</th>\n",
|
735 |
+
" <th>duration_ms</th>\n",
|
736 |
+
" <th>explicit</th>\n",
|
737 |
+
" <th>danceability</th>\n",
|
738 |
+
" <th>energy</th>\n",
|
739 |
+
" <th>key</th>\n",
|
740 |
+
" <th>loudness</th>\n",
|
741 |
+
" <th>mode</th>\n",
|
742 |
+
" <th>speechiness</th>\n",
|
743 |
+
" <th>acousticness</th>\n",
|
744 |
+
" <th>instrumentalness</th>\n",
|
745 |
+
" <th>liveness</th>\n",
|
746 |
+
" <th>valence</th>\n",
|
747 |
+
" <th>tempo</th>\n",
|
748 |
+
" <th>time_signature</th>\n",
|
749 |
+
" <th>track_genre</th>\n",
|
750 |
+
" </tr>\n",
|
751 |
+
" </thead>\n",
|
752 |
+
" <tbody>\n",
|
753 |
+
" <tr>\n",
|
754 |
+
" <th>18</th>\n",
|
755 |
+
" <td>Jason Mraz;Colbie Caillat</td>\n",
|
756 |
+
" <td>Lucky</td>\n",
|
757 |
+
" <td>68</td>\n",
|
758 |
+
" <td>189613</td>\n",
|
759 |
+
" <td>False</td>\n",
|
760 |
+
" <td>0.625</td>\n",
|
761 |
+
" <td>0.414</td>\n",
|
762 |
+
" <td>0</td>\n",
|
763 |
+
" <td>-8.700</td>\n",
|
764 |
+
" <td>1</td>\n",
|
765 |
+
" <td>0.0369</td>\n",
|
766 |
+
" <td>0.29400</td>\n",
|
767 |
+
" <td>0.000000</td>\n",
|
768 |
+
" <td>0.1510</td>\n",
|
769 |
+
" <td>0.6690</td>\n",
|
770 |
+
" <td>130.088</td>\n",
|
771 |
+
" <td>4</td>\n",
|
772 |
+
" <td>acoustic</td>\n",
|
773 |
+
" </tr>\n",
|
774 |
+
" <tr>\n",
|
775 |
+
" <th>20</th>\n",
|
776 |
+
" <td>Jason Mraz</td>\n",
|
777 |
+
" <td>I'm Yours</td>\n",
|
778 |
+
" <td>75</td>\n",
|
779 |
+
" <td>242946</td>\n",
|
780 |
+
" <td>False</td>\n",
|
781 |
+
" <td>0.703</td>\n",
|
782 |
+
" <td>0.444</td>\n",
|
783 |
+
" <td>11</td>\n",
|
784 |
+
" <td>-9.331</td>\n",
|
785 |
+
" <td>1</td>\n",
|
786 |
+
" <td>0.0417</td>\n",
|
787 |
+
" <td>0.55900</td>\n",
|
788 |
+
" <td>0.000000</td>\n",
|
789 |
+
" <td>0.0973</td>\n",
|
790 |
+
" <td>0.7120</td>\n",
|
791 |
+
" <td>150.960</td>\n",
|
792 |
+
" <td>4</td>\n",
|
793 |
+
" <td>acoustic</td>\n",
|
794 |
+
" </tr>\n",
|
795 |
+
" <tr>\n",
|
796 |
+
" <th>22</th>\n",
|
797 |
+
" <td>A Great Big World;Christina Aguilera</td>\n",
|
798 |
+
" <td>Say Something</td>\n",
|
799 |
+
" <td>70</td>\n",
|
800 |
+
" <td>229400</td>\n",
|
801 |
+
" <td>False</td>\n",
|
802 |
+
" <td>0.407</td>\n",
|
803 |
+
" <td>0.147</td>\n",
|
804 |
+
" <td>2</td>\n",
|
805 |
+
" <td>-8.822</td>\n",
|
806 |
+
" <td>1</td>\n",
|
807 |
+
" <td>0.0355</td>\n",
|
808 |
+
" <td>0.85700</td>\n",
|
809 |
+
" <td>0.000003</td>\n",
|
810 |
+
" <td>0.0913</td>\n",
|
811 |
+
" <td>0.0765</td>\n",
|
812 |
+
" <td>141.284</td>\n",
|
813 |
+
" <td>3</td>\n",
|
814 |
+
" <td>acoustic</td>\n",
|
815 |
+
" </tr>\n",
|
816 |
+
" <tr>\n",
|
817 |
+
" <th>28</th>\n",
|
818 |
+
" <td>Jason Mraz</td>\n",
|
819 |
+
" <td>Winter Wonderland</td>\n",
|
820 |
+
" <td>0</td>\n",
|
821 |
+
" <td>131760</td>\n",
|
822 |
+
" <td>False</td>\n",
|
823 |
+
" <td>0.620</td>\n",
|
824 |
+
" <td>0.309</td>\n",
|
825 |
+
" <td>5</td>\n",
|
826 |
+
" <td>-9.209</td>\n",
|
827 |
+
" <td>1</td>\n",
|
828 |
+
" <td>0.0495</td>\n",
|
829 |
+
" <td>0.78800</td>\n",
|
830 |
+
" <td>0.000000</td>\n",
|
831 |
+
" <td>0.1460</td>\n",
|
832 |
+
" <td>0.6640</td>\n",
|
833 |
+
" <td>145.363</td>\n",
|
834 |
+
" <td>4</td>\n",
|
835 |
+
" <td>acoustic</td>\n",
|
836 |
+
" </tr>\n",
|
837 |
+
" <tr>\n",
|
838 |
+
" <th>29</th>\n",
|
839 |
+
" <td>Jason Mraz</td>\n",
|
840 |
+
" <td>Winter Wonderland</td>\n",
|
841 |
+
" <td>0</td>\n",
|
842 |
+
" <td>131760</td>\n",
|
843 |
+
" <td>False</td>\n",
|
844 |
+
" <td>0.620</td>\n",
|
845 |
+
" <td>0.309</td>\n",
|
846 |
+
" <td>5</td>\n",
|
847 |
+
" <td>-9.209</td>\n",
|
848 |
+
" <td>1</td>\n",
|
849 |
+
" <td>0.0495</td>\n",
|
850 |
+
" <td>0.78800</td>\n",
|
851 |
+
" <td>0.000000</td>\n",
|
852 |
+
" <td>0.1460</td>\n",
|
853 |
+
" <td>0.6640</td>\n",
|
854 |
+
" <td>145.363</td>\n",
|
855 |
+
" <td>4</td>\n",
|
856 |
+
" <td>acoustic</td>\n",
|
857 |
+
" </tr>\n",
|
858 |
+
" <tr>\n",
|
859 |
+
" <th>...</th>\n",
|
860 |
+
" <td>...</td>\n",
|
861 |
+
" <td>...</td>\n",
|
862 |
+
" <td>...</td>\n",
|
863 |
+
" <td>...</td>\n",
|
864 |
+
" <td>...</td>\n",
|
865 |
+
" <td>...</td>\n",
|
866 |
+
" <td>...</td>\n",
|
867 |
+
" <td>...</td>\n",
|
868 |
+
" <td>...</td>\n",
|
869 |
+
" <td>...</td>\n",
|
870 |
+
" <td>...</td>\n",
|
871 |
+
" <td>...</td>\n",
|
872 |
+
" <td>...</td>\n",
|
873 |
+
" <td>...</td>\n",
|
874 |
+
" <td>...</td>\n",
|
875 |
+
" <td>...</td>\n",
|
876 |
+
" <td>...</td>\n",
|
877 |
+
" <td>...</td>\n",
|
878 |
+
" </tr>\n",
|
879 |
+
" <tr>\n",
|
880 |
+
" <th>113845</th>\n",
|
881 |
+
" <td>Hillsong Worship;Brooke Ligertwood</td>\n",
|
882 |
+
" <td>King Of Kings - Live at Hillsong Conference</td>\n",
|
883 |
+
" <td>40</td>\n",
|
884 |
+
" <td>291565</td>\n",
|
885 |
+
" <td>False</td>\n",
|
886 |
+
" <td>0.454</td>\n",
|
887 |
+
" <td>0.427</td>\n",
|
888 |
+
" <td>2</td>\n",
|
889 |
+
" <td>-8.049</td>\n",
|
890 |
+
" <td>1</td>\n",
|
891 |
+
" <td>0.0290</td>\n",
|
892 |
+
" <td>0.02050</td>\n",
|
893 |
+
" <td>0.000000</td>\n",
|
894 |
+
" <td>0.6900</td>\n",
|
895 |
+
" <td>0.1840</td>\n",
|
896 |
+
" <td>135.887</td>\n",
|
897 |
+
" <td>4</td>\n",
|
898 |
+
" <td>world-music</td>\n",
|
899 |
+
" </tr>\n",
|
900 |
+
" <tr>\n",
|
901 |
+
" <th>113882</th>\n",
|
902 |
+
" <td>Bryan & Katie Torwalt</td>\n",
|
903 |
+
" <td>Good News - Live</td>\n",
|
904 |
+
" <td>23</td>\n",
|
905 |
+
" <td>266632</td>\n",
|
906 |
+
" <td>False</td>\n",
|
907 |
+
" <td>0.473</td>\n",
|
908 |
+
" <td>0.474</td>\n",
|
909 |
+
" <td>6</td>\n",
|
910 |
+
" <td>-9.175</td>\n",
|
911 |
+
" <td>1</td>\n",
|
912 |
+
" <td>0.0558</td>\n",
|
913 |
+
" <td>0.39500</td>\n",
|
914 |
+
" <td>0.000000</td>\n",
|
915 |
+
" <td>0.1630</td>\n",
|
916 |
+
" <td>0.2510</td>\n",
|
917 |
+
" <td>140.746</td>\n",
|
918 |
+
" <td>4</td>\n",
|
919 |
+
" <td>world-music</td>\n",
|
920 |
+
" </tr>\n",
|
921 |
+
" <tr>\n",
|
922 |
+
" <th>113917</th>\n",
|
923 |
+
" <td>Hillsong Worship;Mi-kaisha Rose</td>\n",
|
924 |
+
" <td>Never Walk Alone - Live</td>\n",
|
925 |
+
" <td>41</td>\n",
|
926 |
+
" <td>348619</td>\n",
|
927 |
+
" <td>False</td>\n",
|
928 |
+
" <td>0.420</td>\n",
|
929 |
+
" <td>0.553</td>\n",
|
930 |
+
" <td>5</td>\n",
|
931 |
+
" <td>-8.049</td>\n",
|
932 |
+
" <td>1</td>\n",
|
933 |
+
" <td>0.0332</td>\n",
|
934 |
+
" <td>0.14100</td>\n",
|
935 |
+
" <td>0.000000</td>\n",
|
936 |
+
" <td>0.1030</td>\n",
|
937 |
+
" <td>0.2140</td>\n",
|
938 |
+
" <td>143.804</td>\n",
|
939 |
+
" <td>4</td>\n",
|
940 |
+
" <td>world-music</td>\n",
|
941 |
+
" </tr>\n",
|
942 |
+
" <tr>\n",
|
943 |
+
" <th>113951</th>\n",
|
944 |
+
" <td>Passion;Kristian Stanfill</td>\n",
|
945 |
+
" <td>More Like Jesus - Live</td>\n",
|
946 |
+
" <td>44</td>\n",
|
947 |
+
" <td>338694</td>\n",
|
948 |
+
" <td>False</td>\n",
|
949 |
+
" <td>0.404</td>\n",
|
950 |
+
" <td>0.676</td>\n",
|
951 |
+
" <td>10</td>\n",
|
952 |
+
" <td>-5.468</td>\n",
|
953 |
+
" <td>1</td>\n",
|
954 |
+
" <td>0.0354</td>\n",
|
955 |
+
" <td>0.02740</td>\n",
|
956 |
+
" <td>0.000000</td>\n",
|
957 |
+
" <td>0.3520</td>\n",
|
958 |
+
" <td>0.1630</td>\n",
|
959 |
+
" <td>144.056</td>\n",
|
960 |
+
" <td>3</td>\n",
|
961 |
+
" <td>world-music</td>\n",
|
962 |
+
" </tr>\n",
|
963 |
+
" <tr>\n",
|
964 |
+
" <th>113991</th>\n",
|
965 |
+
" <td>Chris Tomlin</td>\n",
|
966 |
+
" <td>At The Cross (Love Ran Red)</td>\n",
|
967 |
+
" <td>32</td>\n",
|
968 |
+
" <td>250629</td>\n",
|
969 |
+
" <td>False</td>\n",
|
970 |
+
" <td>0.387</td>\n",
|
971 |
+
" <td>0.531</td>\n",
|
972 |
+
" <td>8</td>\n",
|
973 |
+
" <td>-4.788</td>\n",
|
974 |
+
" <td>1</td>\n",
|
975 |
+
" <td>0.0290</td>\n",
|
976 |
+
" <td>0.00305</td>\n",
|
977 |
+
" <td>0.000000</td>\n",
|
978 |
+
" <td>0.2010</td>\n",
|
979 |
+
" <td>0.1530</td>\n",
|
980 |
+
" <td>146.003</td>\n",
|
981 |
+
" <td>4</td>\n",
|
982 |
+
" <td>world-music</td>\n",
|
983 |
+
" </tr>\n",
|
984 |
+
" </tbody>\n",
|
985 |
+
"</table>\n",
|
986 |
+
"<p>32656 rows × 18 columns</p>\n",
|
987 |
+
"</div>"
|
988 |
+
],
|
989 |
+
"text/plain": [
|
990 |
+
" artists \\\n",
|
991 |
+
"18 Jason Mraz;Colbie Caillat \n",
|
992 |
+
"20 Jason Mraz \n",
|
993 |
+
"22 A Great Big World;Christina Aguilera \n",
|
994 |
+
"28 Jason Mraz \n",
|
995 |
+
"29 Jason Mraz \n",
|
996 |
+
"... ... \n",
|
997 |
+
"113845 Hillsong Worship;Brooke Ligertwood \n",
|
998 |
+
"113882 Bryan & Katie Torwalt \n",
|
999 |
+
"113917 Hillsong Worship;Mi-kaisha Rose \n",
|
1000 |
+
"113951 Passion;Kristian Stanfill \n",
|
1001 |
+
"113991 Chris Tomlin \n",
|
1002 |
+
"\n",
|
1003 |
+
" track_name popularity duration_ms \\\n",
|
1004 |
+
"18 Lucky 68 189613 \n",
|
1005 |
+
"20 I'm Yours 75 242946 \n",
|
1006 |
+
"22 Say Something 70 229400 \n",
|
1007 |
+
"28 Winter Wonderland 0 131760 \n",
|
1008 |
+
"29 Winter Wonderland 0 131760 \n",
|
1009 |
+
"... ... ... ... \n",
|
1010 |
+
"113845 King Of Kings - Live at Hillsong Conference 40 291565 \n",
|
1011 |
+
"113882 Good News - Live 23 266632 \n",
|
1012 |
+
"113917 Never Walk Alone - Live 41 348619 \n",
|
1013 |
+
"113951 More Like Jesus - Live 44 338694 \n",
|
1014 |
+
"113991 At The Cross (Love Ran Red) 32 250629 \n",
|
1015 |
+
"\n",
|
1016 |
+
" explicit danceability energy key loudness mode speechiness \\\n",
|
1017 |
+
"18 False 0.625 0.414 0 -8.700 1 0.0369 \n",
|
1018 |
+
"20 False 0.703 0.444 11 -9.331 1 0.0417 \n",
|
1019 |
+
"22 False 0.407 0.147 2 -8.822 1 0.0355 \n",
|
1020 |
+
"28 False 0.620 0.309 5 -9.209 1 0.0495 \n",
|
1021 |
+
"29 False 0.620 0.309 5 -9.209 1 0.0495 \n",
|
1022 |
+
"... ... ... ... ... ... ... ... \n",
|
1023 |
+
"113845 False 0.454 0.427 2 -8.049 1 0.0290 \n",
|
1024 |
+
"113882 False 0.473 0.474 6 -9.175 1 0.0558 \n",
|
1025 |
+
"113917 False 0.420 0.553 5 -8.049 1 0.0332 \n",
|
1026 |
+
"113951 False 0.404 0.676 10 -5.468 1 0.0354 \n",
|
1027 |
+
"113991 False 0.387 0.531 8 -4.788 1 0.0290 \n",
|
1028 |
+
"\n",
|
1029 |
+
" acousticness instrumentalness liveness valence tempo \\\n",
|
1030 |
+
"18 0.29400 0.000000 0.1510 0.6690 130.088 \n",
|
1031 |
+
"20 0.55900 0.000000 0.0973 0.7120 150.960 \n",
|
1032 |
+
"22 0.85700 0.000003 0.0913 0.0765 141.284 \n",
|
1033 |
+
"28 0.78800 0.000000 0.1460 0.6640 145.363 \n",
|
1034 |
+
"29 0.78800 0.000000 0.1460 0.6640 145.363 \n",
|
1035 |
+
"... ... ... ... ... ... \n",
|
1036 |
+
"113845 0.02050 0.000000 0.6900 0.1840 135.887 \n",
|
1037 |
+
"113882 0.39500 0.000000 0.1630 0.2510 140.746 \n",
|
1038 |
+
"113917 0.14100 0.000000 0.1030 0.2140 143.804 \n",
|
1039 |
+
"113951 0.02740 0.000000 0.3520 0.1630 144.056 \n",
|
1040 |
+
"113991 0.00305 0.000000 0.2010 0.1530 146.003 \n",
|
1041 |
+
"\n",
|
1042 |
+
" time_signature track_genre \n",
|
1043 |
+
"18 4 acoustic \n",
|
1044 |
+
"20 4 acoustic \n",
|
1045 |
+
"22 3 acoustic \n",
|
1046 |
+
"28 4 acoustic \n",
|
1047 |
+
"29 4 acoustic \n",
|
1048 |
+
"... ... ... \n",
|
1049 |
+
"113845 4 world-music \n",
|
1050 |
+
"113882 4 world-music \n",
|
1051 |
+
"113917 4 world-music \n",
|
1052 |
+
"113951 3 world-music \n",
|
1053 |
+
"113991 4 world-music \n",
|
1054 |
+
"\n",
|
1055 |
+
"[32656 rows x 18 columns]"
|
1056 |
+
]
|
1057 |
+
},
|
1058 |
+
"execution_count": 8,
|
1059 |
+
"metadata": {},
|
1060 |
+
"output_type": "execute_result"
|
1061 |
+
}
|
1062 |
+
],
|
1063 |
+
"source": [
|
1064 |
+
"duplicated_rows = df[df.duplicated(['artists', 'track_name'])]\n",
|
1065 |
+
"\n",
|
1066 |
+
"# print duplicated rows\n",
|
1067 |
+
"duplicated_rows"
|
1068 |
+
]
|
1069 |
+
},
|
1070 |
+
{
|
1071 |
+
"cell_type": "code",
|
1072 |
+
"execution_count": 9,
|
1073 |
+
"id": "251df65d",
|
1074 |
+
"metadata": {},
|
1075 |
+
"outputs": [],
|
1076 |
+
"source": [
|
1077 |
+
"df = df.drop_duplicates(['artists', 'track_name'], keep='first')"
|
1078 |
+
]
|
1079 |
+
},
|
1080 |
+
{
|
1081 |
+
"cell_type": "code",
|
1082 |
+
"execution_count": 10,
|
1083 |
+
"id": "d6eea5b5",
|
1084 |
+
"metadata": {},
|
1085 |
+
"outputs": [
|
1086 |
+
{
|
1087 |
+
"data": {
|
1088 |
+
"text/plain": [
|
1089 |
+
"study 996\n",
|
1090 |
+
"black-metal 991\n",
|
1091 |
+
"comedy 987\n",
|
1092 |
+
"heavy-metal 985\n",
|
1093 |
+
"bluegrass 978\n",
|
1094 |
+
" ... \n",
|
1095 |
+
"rock 167\n",
|
1096 |
+
"reggae 166\n",
|
1097 |
+
"house 134\n",
|
1098 |
+
"indie 107\n",
|
1099 |
+
"reggaeton 63\n",
|
1100 |
+
"Name: track_genre, Length: 113, dtype: int64"
|
1101 |
+
]
|
1102 |
+
},
|
1103 |
+
"execution_count": 10,
|
1104 |
+
"metadata": {},
|
1105 |
+
"output_type": "execute_result"
|
1106 |
+
}
|
1107 |
+
],
|
1108 |
+
"source": [
|
1109 |
+
"df.shape\n",
|
1110 |
+
"df['track_genre'].value_counts()"
|
1111 |
+
]
|
1112 |
+
},
|
1113 |
+
{
|
1114 |
+
"attachments": {},
|
1115 |
+
"cell_type": "markdown",
|
1116 |
+
"id": "363cf332",
|
1117 |
+
"metadata": {},
|
1118 |
+
"source": [
|
1119 |
+
"### Drop artists and track name columns"
|
1120 |
+
]
|
1121 |
+
},
|
1122 |
+
{
|
1123 |
+
"cell_type": "code",
|
1124 |
+
"execution_count": 11,
|
1125 |
+
"id": "2f11bf72",
|
1126 |
+
"metadata": {},
|
1127 |
+
"outputs": [
|
1128 |
+
{
|
1129 |
+
"data": {
|
1130 |
+
"text/html": [
|
1131 |
+
"<div>\n",
|
1132 |
+
"<style scoped>\n",
|
1133 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
1134 |
+
" vertical-align: middle;\n",
|
1135 |
+
" }\n",
|
1136 |
+
"\n",
|
1137 |
+
" .dataframe tbody tr th {\n",
|
1138 |
+
" vertical-align: top;\n",
|
1139 |
+
" }\n",
|
1140 |
+
"\n",
|
1141 |
+
" .dataframe thead th {\n",
|
1142 |
+
" text-align: right;\n",
|
1143 |
+
" }\n",
|
1144 |
+
"</style>\n",
|
1145 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1146 |
+
" <thead>\n",
|
1147 |
+
" <tr style=\"text-align: right;\">\n",
|
1148 |
+
" <th></th>\n",
|
1149 |
+
" <th>popularity</th>\n",
|
1150 |
+
" <th>duration_ms</th>\n",
|
1151 |
+
" <th>explicit</th>\n",
|
1152 |
+
" <th>danceability</th>\n",
|
1153 |
+
" <th>energy</th>\n",
|
1154 |
+
" <th>key</th>\n",
|
1155 |
+
" <th>loudness</th>\n",
|
1156 |
+
" <th>mode</th>\n",
|
1157 |
+
" <th>speechiness</th>\n",
|
1158 |
+
" <th>acousticness</th>\n",
|
1159 |
+
" <th>instrumentalness</th>\n",
|
1160 |
+
" <th>liveness</th>\n",
|
1161 |
+
" <th>valence</th>\n",
|
1162 |
+
" <th>tempo</th>\n",
|
1163 |
+
" <th>time_signature</th>\n",
|
1164 |
+
" <th>track_genre</th>\n",
|
1165 |
+
" </tr>\n",
|
1166 |
+
" </thead>\n",
|
1167 |
+
" <tbody>\n",
|
1168 |
+
" <tr>\n",
|
1169 |
+
" <th>0</th>\n",
|
1170 |
+
" <td>73</td>\n",
|
1171 |
+
" <td>230666</td>\n",
|
1172 |
+
" <td>False</td>\n",
|
1173 |
+
" <td>0.676</td>\n",
|
1174 |
+
" <td>0.4610</td>\n",
|
1175 |
+
" <td>1</td>\n",
|
1176 |
+
" <td>-6.746</td>\n",
|
1177 |
+
" <td>0</td>\n",
|
1178 |
+
" <td>0.1430</td>\n",
|
1179 |
+
" <td>0.0322</td>\n",
|
1180 |
+
" <td>0.000001</td>\n",
|
1181 |
+
" <td>0.3580</td>\n",
|
1182 |
+
" <td>0.715</td>\n",
|
1183 |
+
" <td>87.917</td>\n",
|
1184 |
+
" <td>4</td>\n",
|
1185 |
+
" <td>acoustic</td>\n",
|
1186 |
+
" </tr>\n",
|
1187 |
+
" <tr>\n",
|
1188 |
+
" <th>1</th>\n",
|
1189 |
+
" <td>55</td>\n",
|
1190 |
+
" <td>149610</td>\n",
|
1191 |
+
" <td>False</td>\n",
|
1192 |
+
" <td>0.420</td>\n",
|
1193 |
+
" <td>0.1660</td>\n",
|
1194 |
+
" <td>1</td>\n",
|
1195 |
+
" <td>-17.235</td>\n",
|
1196 |
+
" <td>1</td>\n",
|
1197 |
+
" <td>0.0763</td>\n",
|
1198 |
+
" <td>0.9240</td>\n",
|
1199 |
+
" <td>0.000006</td>\n",
|
1200 |
+
" <td>0.1010</td>\n",
|
1201 |
+
" <td>0.267</td>\n",
|
1202 |
+
" <td>77.489</td>\n",
|
1203 |
+
" <td>4</td>\n",
|
1204 |
+
" <td>acoustic</td>\n",
|
1205 |
+
" </tr>\n",
|
1206 |
+
" <tr>\n",
|
1207 |
+
" <th>2</th>\n",
|
1208 |
+
" <td>57</td>\n",
|
1209 |
+
" <td>210826</td>\n",
|
1210 |
+
" <td>False</td>\n",
|
1211 |
+
" <td>0.438</td>\n",
|
1212 |
+
" <td>0.3590</td>\n",
|
1213 |
+
" <td>0</td>\n",
|
1214 |
+
" <td>-9.734</td>\n",
|
1215 |
+
" <td>1</td>\n",
|
1216 |
+
" <td>0.0557</td>\n",
|
1217 |
+
" <td>0.2100</td>\n",
|
1218 |
+
" <td>0.000000</td>\n",
|
1219 |
+
" <td>0.1170</td>\n",
|
1220 |
+
" <td>0.120</td>\n",
|
1221 |
+
" <td>76.332</td>\n",
|
1222 |
+
" <td>4</td>\n",
|
1223 |
+
" <td>acoustic</td>\n",
|
1224 |
+
" </tr>\n",
|
1225 |
+
" <tr>\n",
|
1226 |
+
" <th>3</th>\n",
|
1227 |
+
" <td>71</td>\n",
|
1228 |
+
" <td>201933</td>\n",
|
1229 |
+
" <td>False</td>\n",
|
1230 |
+
" <td>0.266</td>\n",
|
1231 |
+
" <td>0.0596</td>\n",
|
1232 |
+
" <td>0</td>\n",
|
1233 |
+
" <td>-18.515</td>\n",
|
1234 |
+
" <td>1</td>\n",
|
1235 |
+
" <td>0.0363</td>\n",
|
1236 |
+
" <td>0.9050</td>\n",
|
1237 |
+
" <td>0.000071</td>\n",
|
1238 |
+
" <td>0.1320</td>\n",
|
1239 |
+
" <td>0.143</td>\n",
|
1240 |
+
" <td>181.740</td>\n",
|
1241 |
+
" <td>3</td>\n",
|
1242 |
+
" <td>acoustic</td>\n",
|
1243 |
+
" </tr>\n",
|
1244 |
+
" <tr>\n",
|
1245 |
+
" <th>4</th>\n",
|
1246 |
+
" <td>82</td>\n",
|
1247 |
+
" <td>198853</td>\n",
|
1248 |
+
" <td>False</td>\n",
|
1249 |
+
" <td>0.618</td>\n",
|
1250 |
+
" <td>0.4430</td>\n",
|
1251 |
+
" <td>2</td>\n",
|
1252 |
+
" <td>-9.681</td>\n",
|
1253 |
+
" <td>1</td>\n",
|
1254 |
+
" <td>0.0526</td>\n",
|
1255 |
+
" <td>0.4690</td>\n",
|
1256 |
+
" <td>0.000000</td>\n",
|
1257 |
+
" <td>0.0829</td>\n",
|
1258 |
+
" <td>0.167</td>\n",
|
1259 |
+
" <td>119.949</td>\n",
|
1260 |
+
" <td>4</td>\n",
|
1261 |
+
" <td>acoustic</td>\n",
|
1262 |
+
" </tr>\n",
|
1263 |
+
" </tbody>\n",
|
1264 |
+
"</table>\n",
|
1265 |
+
"</div>"
|
1266 |
+
],
|
1267 |
+
"text/plain": [
|
1268 |
+
" popularity duration_ms explicit danceability energy key loudness \\\n",
|
1269 |
+
"0 73 230666 False 0.676 0.4610 1 -6.746 \n",
|
1270 |
+
"1 55 149610 False 0.420 0.1660 1 -17.235 \n",
|
1271 |
+
"2 57 210826 False 0.438 0.3590 0 -9.734 \n",
|
1272 |
+
"3 71 201933 False 0.266 0.0596 0 -18.515 \n",
|
1273 |
+
"4 82 198853 False 0.618 0.4430 2 -9.681 \n",
|
1274 |
+
"\n",
|
1275 |
+
" mode speechiness acousticness instrumentalness liveness valence \\\n",
|
1276 |
+
"0 0 0.1430 0.0322 0.000001 0.3580 0.715 \n",
|
1277 |
+
"1 1 0.0763 0.9240 0.000006 0.1010 0.267 \n",
|
1278 |
+
"2 1 0.0557 0.2100 0.000000 0.1170 0.120 \n",
|
1279 |
+
"3 1 0.0363 0.9050 0.000071 0.1320 0.143 \n",
|
1280 |
+
"4 1 0.0526 0.4690 0.000000 0.0829 0.167 \n",
|
1281 |
+
"\n",
|
1282 |
+
" tempo time_signature track_genre \n",
|
1283 |
+
"0 87.917 4 acoustic \n",
|
1284 |
+
"1 77.489 4 acoustic \n",
|
1285 |
+
"2 76.332 4 acoustic \n",
|
1286 |
+
"3 181.740 3 acoustic \n",
|
1287 |
+
"4 119.949 4 acoustic "
|
1288 |
+
]
|
1289 |
+
},
|
1290 |
+
"execution_count": 11,
|
1291 |
+
"metadata": {},
|
1292 |
+
"output_type": "execute_result"
|
1293 |
+
}
|
1294 |
+
],
|
1295 |
+
"source": [
|
1296 |
+
"df = df.drop(['artists','track_name'],axis=1)\n",
|
1297 |
+
"df.head()"
|
1298 |
+
]
|
1299 |
+
},
|
1300 |
+
{
|
1301 |
+
"attachments": {},
|
1302 |
+
"cell_type": "markdown",
|
1303 |
+
"id": "e7d572f5",
|
1304 |
+
"metadata": {},
|
1305 |
+
"source": [
|
1306 |
+
"### Drop invalid tempo and time signature according to Spotify API"
|
1307 |
+
]
|
1308 |
+
},
|
1309 |
+
{
|
1310 |
+
"cell_type": "code",
|
1311 |
+
"execution_count": 12,
|
1312 |
+
"id": "69b1cceb",
|
1313 |
+
"metadata": {},
|
1314 |
+
"outputs": [
|
1315 |
+
{
|
1316 |
+
"data": {
|
1317 |
+
"text/plain": [
|
1318 |
+
"4 71986\n",
|
1319 |
+
"3 6944\n",
|
1320 |
+
"5 1488\n",
|
1321 |
+
"1 775\n",
|
1322 |
+
"0 150\n",
|
1323 |
+
"Name: time_signature, dtype: int64"
|
1324 |
+
]
|
1325 |
+
},
|
1326 |
+
"execution_count": 12,
|
1327 |
+
"metadata": {},
|
1328 |
+
"output_type": "execute_result"
|
1329 |
+
}
|
1330 |
+
],
|
1331 |
+
"source": [
|
1332 |
+
"df['time_signature'].value_counts()"
|
1333 |
+
]
|
1334 |
+
},
|
1335 |
+
{
|
1336 |
+
"cell_type": "code",
|
1337 |
+
"execution_count": 13,
|
1338 |
+
"id": "39a08b22",
|
1339 |
+
"metadata": {},
|
1340 |
+
"outputs": [],
|
1341 |
+
"source": [
|
1342 |
+
"df = df[df['time_signature'] >2]\n",
|
1343 |
+
"df = df[df['tempo'] > 0]"
|
1344 |
+
]
|
1345 |
+
},
|
1346 |
+
{
|
1347 |
+
"attachments": {},
|
1348 |
+
"cell_type": "markdown",
|
1349 |
+
"id": "0b7c8cea",
|
1350 |
+
"metadata": {},
|
1351 |
+
"source": [
|
1352 |
+
"### Save the cleaned dataset into csv"
|
1353 |
+
]
|
1354 |
+
},
|
1355 |
+
{
|
1356 |
+
"cell_type": "code",
|
1357 |
+
"execution_count": 14,
|
1358 |
+
"id": "8c064cb0",
|
1359 |
+
"metadata": {},
|
1360 |
+
"outputs": [
|
1361 |
+
{
|
1362 |
+
"data": {
|
1363 |
+
"text/html": [
|
1364 |
+
"<div>\n",
|
1365 |
+
"<style scoped>\n",
|
1366 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
1367 |
+
" vertical-align: middle;\n",
|
1368 |
+
" }\n",
|
1369 |
+
"\n",
|
1370 |
+
" .dataframe tbody tr th {\n",
|
1371 |
+
" vertical-align: top;\n",
|
1372 |
+
" }\n",
|
1373 |
+
"\n",
|
1374 |
+
" .dataframe thead th {\n",
|
1375 |
+
" text-align: right;\n",
|
1376 |
+
" }\n",
|
1377 |
+
"</style>\n",
|
1378 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1379 |
+
" <thead>\n",
|
1380 |
+
" <tr style=\"text-align: right;\">\n",
|
1381 |
+
" <th></th>\n",
|
1382 |
+
" <th>popularity</th>\n",
|
1383 |
+
" <th>duration_ms</th>\n",
|
1384 |
+
" <th>explicit</th>\n",
|
1385 |
+
" <th>danceability</th>\n",
|
1386 |
+
" <th>energy</th>\n",
|
1387 |
+
" <th>key</th>\n",
|
1388 |
+
" <th>loudness</th>\n",
|
1389 |
+
" <th>mode</th>\n",
|
1390 |
+
" <th>speechiness</th>\n",
|
1391 |
+
" <th>acousticness</th>\n",
|
1392 |
+
" <th>instrumentalness</th>\n",
|
1393 |
+
" <th>liveness</th>\n",
|
1394 |
+
" <th>valence</th>\n",
|
1395 |
+
" <th>tempo</th>\n",
|
1396 |
+
" <th>time_signature</th>\n",
|
1397 |
+
" <th>track_genre</th>\n",
|
1398 |
+
" </tr>\n",
|
1399 |
+
" </thead>\n",
|
1400 |
+
" <tbody>\n",
|
1401 |
+
" <tr>\n",
|
1402 |
+
" <th>0</th>\n",
|
1403 |
+
" <td>73</td>\n",
|
1404 |
+
" <td>230666</td>\n",
|
1405 |
+
" <td>False</td>\n",
|
1406 |
+
" <td>0.676</td>\n",
|
1407 |
+
" <td>0.4610</td>\n",
|
1408 |
+
" <td>1</td>\n",
|
1409 |
+
" <td>-6.746</td>\n",
|
1410 |
+
" <td>0</td>\n",
|
1411 |
+
" <td>0.1430</td>\n",
|
1412 |
+
" <td>0.0322</td>\n",
|
1413 |
+
" <td>0.000001</td>\n",
|
1414 |
+
" <td>0.3580</td>\n",
|
1415 |
+
" <td>0.715</td>\n",
|
1416 |
+
" <td>87.917</td>\n",
|
1417 |
+
" <td>4</td>\n",
|
1418 |
+
" <td>acoustic</td>\n",
|
1419 |
+
" </tr>\n",
|
1420 |
+
" <tr>\n",
|
1421 |
+
" <th>1</th>\n",
|
1422 |
+
" <td>55</td>\n",
|
1423 |
+
" <td>149610</td>\n",
|
1424 |
+
" <td>False</td>\n",
|
1425 |
+
" <td>0.420</td>\n",
|
1426 |
+
" <td>0.1660</td>\n",
|
1427 |
+
" <td>1</td>\n",
|
1428 |
+
" <td>-17.235</td>\n",
|
1429 |
+
" <td>1</td>\n",
|
1430 |
+
" <td>0.0763</td>\n",
|
1431 |
+
" <td>0.9240</td>\n",
|
1432 |
+
" <td>0.000006</td>\n",
|
1433 |
+
" <td>0.1010</td>\n",
|
1434 |
+
" <td>0.267</td>\n",
|
1435 |
+
" <td>77.489</td>\n",
|
1436 |
+
" <td>4</td>\n",
|
1437 |
+
" <td>acoustic</td>\n",
|
1438 |
+
" </tr>\n",
|
1439 |
+
" <tr>\n",
|
1440 |
+
" <th>2</th>\n",
|
1441 |
+
" <td>57</td>\n",
|
1442 |
+
" <td>210826</td>\n",
|
1443 |
+
" <td>False</td>\n",
|
1444 |
+
" <td>0.438</td>\n",
|
1445 |
+
" <td>0.3590</td>\n",
|
1446 |
+
" <td>0</td>\n",
|
1447 |
+
" <td>-9.734</td>\n",
|
1448 |
+
" <td>1</td>\n",
|
1449 |
+
" <td>0.0557</td>\n",
|
1450 |
+
" <td>0.2100</td>\n",
|
1451 |
+
" <td>0.000000</td>\n",
|
1452 |
+
" <td>0.1170</td>\n",
|
1453 |
+
" <td>0.120</td>\n",
|
1454 |
+
" <td>76.332</td>\n",
|
1455 |
+
" <td>4</td>\n",
|
1456 |
+
" <td>acoustic</td>\n",
|
1457 |
+
" </tr>\n",
|
1458 |
+
" <tr>\n",
|
1459 |
+
" <th>3</th>\n",
|
1460 |
+
" <td>71</td>\n",
|
1461 |
+
" <td>201933</td>\n",
|
1462 |
+
" <td>False</td>\n",
|
1463 |
+
" <td>0.266</td>\n",
|
1464 |
+
" <td>0.0596</td>\n",
|
1465 |
+
" <td>0</td>\n",
|
1466 |
+
" <td>-18.515</td>\n",
|
1467 |
+
" <td>1</td>\n",
|
1468 |
+
" <td>0.0363</td>\n",
|
1469 |
+
" <td>0.9050</td>\n",
|
1470 |
+
" <td>0.000071</td>\n",
|
1471 |
+
" <td>0.1320</td>\n",
|
1472 |
+
" <td>0.143</td>\n",
|
1473 |
+
" <td>181.740</td>\n",
|
1474 |
+
" <td>3</td>\n",
|
1475 |
+
" <td>acoustic</td>\n",
|
1476 |
+
" </tr>\n",
|
1477 |
+
" <tr>\n",
|
1478 |
+
" <th>4</th>\n",
|
1479 |
+
" <td>82</td>\n",
|
1480 |
+
" <td>198853</td>\n",
|
1481 |
+
" <td>False</td>\n",
|
1482 |
+
" <td>0.618</td>\n",
|
1483 |
+
" <td>0.4430</td>\n",
|
1484 |
+
" <td>2</td>\n",
|
1485 |
+
" <td>-9.681</td>\n",
|
1486 |
+
" <td>1</td>\n",
|
1487 |
+
" <td>0.0526</td>\n",
|
1488 |
+
" <td>0.4690</td>\n",
|
1489 |
+
" <td>0.000000</td>\n",
|
1490 |
+
" <td>0.0829</td>\n",
|
1491 |
+
" <td>0.167</td>\n",
|
1492 |
+
" <td>119.949</td>\n",
|
1493 |
+
" <td>4</td>\n",
|
1494 |
+
" <td>acoustic</td>\n",
|
1495 |
+
" </tr>\n",
|
1496 |
+
" </tbody>\n",
|
1497 |
+
"</table>\n",
|
1498 |
+
"</div>"
|
1499 |
+
],
|
1500 |
+
"text/plain": [
|
1501 |
+
" popularity duration_ms explicit danceability energy key loudness \\\n",
|
1502 |
+
"0 73 230666 False 0.676 0.4610 1 -6.746 \n",
|
1503 |
+
"1 55 149610 False 0.420 0.1660 1 -17.235 \n",
|
1504 |
+
"2 57 210826 False 0.438 0.3590 0 -9.734 \n",
|
1505 |
+
"3 71 201933 False 0.266 0.0596 0 -18.515 \n",
|
1506 |
+
"4 82 198853 False 0.618 0.4430 2 -9.681 \n",
|
1507 |
+
"\n",
|
1508 |
+
" mode speechiness acousticness instrumentalness liveness valence \\\n",
|
1509 |
+
"0 0 0.1430 0.0322 0.000001 0.3580 0.715 \n",
|
1510 |
+
"1 1 0.0763 0.9240 0.000006 0.1010 0.267 \n",
|
1511 |
+
"2 1 0.0557 0.2100 0.000000 0.1170 0.120 \n",
|
1512 |
+
"3 1 0.0363 0.9050 0.000071 0.1320 0.143 \n",
|
1513 |
+
"4 1 0.0526 0.4690 0.000000 0.0829 0.167 \n",
|
1514 |
+
"\n",
|
1515 |
+
" tempo time_signature track_genre \n",
|
1516 |
+
"0 87.917 4 acoustic \n",
|
1517 |
+
"1 77.489 4 acoustic \n",
|
1518 |
+
"2 76.332 4 acoustic \n",
|
1519 |
+
"3 181.740 3 acoustic \n",
|
1520 |
+
"4 119.949 4 acoustic "
|
1521 |
+
]
|
1522 |
+
},
|
1523 |
+
"execution_count": 14,
|
1524 |
+
"metadata": {},
|
1525 |
+
"output_type": "execute_result"
|
1526 |
+
}
|
1527 |
+
],
|
1528 |
+
"source": [
|
1529 |
+
"df.head()"
|
1530 |
+
]
|
1531 |
+
},
|
1532 |
+
{
|
1533 |
+
"cell_type": "code",
|
1534 |
+
"execution_count": 15,
|
1535 |
+
"id": "12bea66e",
|
1536 |
+
"metadata": {},
|
1537 |
+
"outputs": [],
|
1538 |
+
"source": [
|
1539 |
+
"df.to_csv(\"cleaned_dataset.csv\",index = False)"
|
1540 |
+
]
|
1541 |
+
}
|
1542 |
+
],
|
1543 |
+
"metadata": {
|
1544 |
+
"kernelspec": {
|
1545 |
+
"display_name": "Python 3 (ipykernel)",
|
1546 |
+
"language": "python",
|
1547 |
+
"name": "python3"
|
1548 |
+
},
|
1549 |
+
"language_info": {
|
1550 |
+
"codemirror_mode": {
|
1551 |
+
"name": "ipython",
|
1552 |
+
"version": 3
|
1553 |
+
},
|
1554 |
+
"file_extension": ".py",
|
1555 |
+
"mimetype": "text/x-python",
|
1556 |
+
"name": "python",
|
1557 |
+
"nbconvert_exporter": "python",
|
1558 |
+
"pygments_lexer": "ipython3",
|
1559 |
+
"version": "3.10.6"
|
1560 |
+
}
|
1561 |
+
},
|
1562 |
+
"nbformat": 4,
|
1563 |
+
"nbformat_minor": 5
|
1564 |
+
}
|
Exploratory Data Analysis.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
Model Building.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
README.md
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Music Popularity Prediction
|
2 |
+
|
3 |
+
This repository contains a data science project that aims to predict the popularity of music using machine learning techniques.
|
4 |
+
|
5 |
+
## Dataset
|
6 |
+
|
7 |
+
This project uses the [Spotify Tracks Dataset](https://www.kaggle.com/datasets/maharshipandya/-spotify-tracks-dataset) available on Kaggle. This dataset contains information about Spotify tracks over a range of 125 different genres. Each track has several audio features associated with it, such as popularity, explicitness, danceability, energy, key, mode, speechiness, acousticness, instrumentalness, liveness, valence, tempo, and time signature.
|
8 |
+
|
9 |
+
You can download the dataset from the Kaggle website and use it to follow along with the analysis in this project.
|
10 |
+
|
11 |
+
## Overview
|
12 |
+
|
13 |
+
This repository contains a data science project that aims to predict the popularity of music using machine learning techniques. The project is a binary classification problem where the goal is to predict whether a song will be popular or not. The dataset used in this project is imbalanced, meaning that one class is significantly more common than the other.
|
14 |
+
|
15 |
+
The project consists of three main parts: Data Cleaning, Exploratory Data Analysis, and Model Building.
|
16 |
+
|
17 |
+
### Data Cleaning
|
18 |
+
|
19 |
+
In the [Data Cleaning](https://github.com/diivien/Music-Popularity-Prediction/blob/master/Data%20Cleaning.ipynb) notebook, I clean and preprocess the data to prepare it for analysis. This involves several steps such as:
|
20 |
+
|
21 |
+
- Removing unique columns
|
22 |
+
- Dropping null values
|
23 |
+
- Dropping duplicated rows (same artists and track name)
|
24 |
+
- Dropping artists and track name columns
|
25 |
+
- Dropping invalid tempo and time signature according to Spotify API
|
26 |
+
- Saving the cleaned dataset into a CSV file
|
27 |
+
|
28 |
+
To get started with the data cleaning process, you can follow the instructions in the Data Cleaning notebook. This will guide you through the steps involved in cleaning and preprocessing the data.
|
29 |
+
|
30 |
+
### Exploratory Data Analysis
|
31 |
+
|
32 |
+
In the [Exploratory Data Analysis](https://github.com/diivien/Music-Popularity-Prediction/blob/master/Exploratory%20Data%20Analysis.ipynb) notebook, we explore the data and gain insights into the relationships between the features and the target variable. This involves generating various visualizations such as:
|
33 |
+
|
34 |
+
- Correlation heatmaps to examine the relationships between pairs of continuous features
|
35 |
+
- Histograms to check the distribution of continuous features
|
36 |
+
- Bar charts to visualize categorical features
|
37 |
+
- Scatter plots to examine the relationships between pairs of continuous features
|
38 |
+
- Box plots to examine the distribution of continuous features by category
|
39 |
+
- Stacked bar charts to visualize conditional distributions
|
40 |
+
|
41 |
+
These visualizations help us understand the data better and inform our decisions when building machine learning models.
|
42 |
+
|
43 |
+
To get started with the exploratory data analysis process, you can follow the instructions in the Exploratory Data Analysis notebook. This will guide you through the steps involved in exploring and visualizing the data.
|
44 |
+
|
45 |
+
### Model Building
|
46 |
+
|
47 |
+
In the [Model Building](https://github.com/diivien/Music-Popularity-Prediction/blob/master/Model%20Building.ipynb) notebook, I build and evaluate machine learning models to predict music popularity. The models used in this analysis include Linear SVC, Random Forest Classifier, LightGBM, and CatBoost. As part of this process, I perform several preprocessing steps such as scaling the data using a MinMax scaler and encoding categorical variables using a target encoder. I also use SMOTE-NC in an imbalanced-learn pipeline to prevent data leakage.
|
48 |
+
|
49 |
+
To tune the hyperparameters of our models, I use Optuna for multi-objective optimization and generate a Pareto front plot to determine the best hyperparameters.
|
50 |
+
|
51 |
+
To evaluate the performance of our models, I use several metrics that are appropriate for imbalanced datasets, such as F1 score, balanced accuracy, and PR AUC.
|
52 |
+
|
53 |
+
To get started with the model building process, you can follow the instructions in the Model Building notebook. This will guide you through the steps involved in building and evaluating machine learning models to predict music popularity.
|
54 |
+
|
55 |
+
## Future Work
|
56 |
+
|
57 |
+
I am currently working on several improvements and extensions to this project. Some include:
|
58 |
+
|
59 |
+
- Testing a neural network classifier to see if it can improve the accuracy of our predictions
|
60 |
+
- Deploying an app on Gradle to make it easier for users to interact with our models and make predictions
|
61 |
+
|
62 |
+
|
63 |
+
## Citations
|
64 |
+
|
65 |
+
If you use any of the following libraries in your project, please cite them as follows:
|
66 |
+
|
67 |
+
- imbalanced-learn: Lemaître, G., Nogueira, F., & Aridas, C. K. (2017). Imbalanced-learn: A Python Toolbox to Tackle the Curse of Imbalanced Datasets in Machine Learning. Journal of Machine Learning Research, 18(17), 1-5.
|
68 |
+
- Matplotlib: Hunter, J. D. (2007). Matplotlib: A 2D graphics environment. Computing in Science & Engineering, 9(3), 90-95.
|
69 |
+
- Seaborn: Waskom, M., Botvinnik, O., O’Kane, D., Hobson, P., Lukauskas, S., Gemperline, D. C., ... & de Ruiter, J. (2021). seaborn: statistical data visualization. Journal of Open Source Software, 6(60), 3021.
|
70 |
+
- Joblib: Buitinck, L., Louppe, G., Blondel, M., Pedregosa, F., Mueller, A., Grisel, O., ... & Duchesnay, E. (2013). API design for machine learning software: experiences from the scikit-learn project. arXiv preprint arXiv:1309.0238.
|
71 |
+
- Feature-engine: Sole-Ribalta A. (2020) Feature-engine: A Python Package for Feature Engineering and Preprocessing in Machine Learning. In: Martínez-Villaseñor L., Batyrshin I., Mendoza O., Kuri-Morales Á. (eds) Advances in Artificial Intelligence - IBERAMIA 2020. IBERAMIA 2020. Lecture Notes in Computer Science, vol 12422. Springer, Cham.
|
72 |
+
- LightGBM: Ke, G., Meng, Q., Finley, T., Wang, T., Chen, W., Ma, W., ... & Liu, T. Y. (2017). LightGBM: A highly efficient gradient boosting decision tree. Advances in Neural Information Processing Systems.
|
73 |
+
- CatBoost: Prokhorenkova L.O., Gusev G.L., Vorobev A.V., Dorogush A.V., Gulin A.A.(2018). CatBoost: unbiased boosting with categorical features. Advances in Neural Information Processing Systems.
|
74 |
+
- Category Encoders: Micci-Barreca D (2001) A preprocessing scheme for high-cardinality categorical attributes in classification and prediction problems. ACM SIGKDD Explorations Newsletter 3(1):27–32
|
75 |
+
- NumPy: Harris CR et al.(2020) Array programming with NumPy. Nature 585(7825):357–362
|
76 |
+
- SDV (Synthetic Data Vault): Patki N et al.(2016) The Synthetic Data Vault. IEEE International Conference on Data Science and Advanced Analytics
|
77 |
+
- Optuna: Akiba T et al.(2019) Optuna: A Next-generation Hyperparameter Optimization Framework. Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining
|
78 |
+
- PyTorch: Paszke A et al.(2019) PyTorch: An Imperative Style High-performance Deep Learning Library. Advances in Neural Information Processing Systems
|
79 |
+
- SciKeras: Varma P et al.(2020) SciKeras: a high-level Scikit-Learn compatible API for TensorFlow's Keras module
|
cleaned_dataset.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
dataset.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|