https://github.com/fatihilhan42/spotify-songs-recommendations-system_with_python
We developed a song recommendation system for the user with the data we received from our Spotify song dataset. Data set and other applications are given in the description. Have a nice day.
https://github.com/fatihilhan42/spotify-songs-recommendations-system_with_python
data-analysis data-science data-visualization jupyter-notebook python recommendation-engine recommendation-system
Last synced: 2 months ago
JSON representation
We developed a song recommendation system for the user with the data we received from our Spotify song dataset. Data set and other applications are given in the description. Have a nice day.
- Host: GitHub
- URL: https://github.com/fatihilhan42/spotify-songs-recommendations-system_with_python
- Owner: fatihilhan42
- Created: 2022-08-01T06:54:57.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-01T07:06:31.000Z (almost 3 years ago)
- Last Synced: 2025-01-29T06:24:56.284Z (4 months ago)
- Topics: data-analysis, data-science, data-visualization, jupyter-notebook, python, recommendation-engine, recommendation-system
- Language: Jupyter Notebook
- Homepage:
- Size: 5.39 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spotify-Songs-Recommendations-System_with_python
We developed a song recommendation system for the user with the data we received from our Spotify song dataset. Data set and other applications are given in the description. Have a nice day.### import
```Python
import pandas as pd
import numpy as np
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
import matplotlib.pyplot as plt
import plotly
from sklearn.preprocessing import StandardScaler
from scipy.spatial import distance
import copy
import warningswarnings.filterwarnings("ignore")
plotly.offline.init_notebook_mode (connected = True)
```
## Having First Look At The Data
```Python
data.head()
```
```Python
cols=list(data.columns[11:])
del cols[7]
df=copy.deepcopy(data)
df.drop(columns=cols,inplace=True)
sns.set(style="ticks", context="talk")
plt.style.use("dark_background")
sns.pairplot(df,corner=True,hue='genre')
```
```Python
px.box(data_frame=data,y='duration_ms',color='genre')
```
```Python
x=list(data.corr().columns)
y=list(data.corr().index)
values=np.array(data.corr().values)
fig = go.Figure(data=go.Heatmap(
z=values,
x=x,
y=y,
hoverongaps = False))
fig.show()
```
## Let's Make A Recommendation System
```Python
data=data.dropna(subset=['song_name'])
```## Creating a new dataframe with required features
```Python
# Making a weight matrix using euclidean distance
def make_matrix(data,song,number):
df=pd.DataFrame()
data.drop_duplicates(inplace=True)
songs=data['song_name'].values
# best = difflib.get_close_matches(song,songs,1)[0]
best=find_word(song,songs)
print('The song closest to your search is :',best)
genre=data[data['song_name']==best]['genre'].values[0]
df=data[data['genre']==genre]
x=df[df['song_name']==best].drop(columns=['genre','song_name']).values
if len(x)>1:
x=x[1]
song_names=df['song_name'].values
df.drop(columns=['genre','song_name'],inplace=True)
df=df.fillna(df.mean())
p=[]
count=0
for i in df.values:
p.append([distance.euclidean(x,i),count])
count+=1
p.sort()
for i in range(1,number+1):
print(song_names[p[i][1]])
```
```Python
a=input('Please enter The name of the song :')
b=int(input('Please enter the number of recommendations you want: '))
make_matrix(df,a,b)
```

```Python
def make_matrix_correlation(data,song,number):
df=pd.DataFrame()
data.drop_duplicates(inplace=True)
songs=data['song_name'].values
# best = difflib.get_close_matches(song,songs,1)[0]
best=find_word(song,songs)
print('The song closest to your search is :',best)
genre=data[data['song_name']==best]['genre'].values[0]
df=data[data['genre']==genre]
x=df[df['song_name']==best].drop(columns=['genre','song_name']).values
if len(x)>1:
x=x[1]
song_names=df['song_name'].values
df.drop(columns=['genre','song_name'],inplace=True)
df=df.fillna(df.mean())
p=[]
count=0
for i in df.values:
p.append([distance.correlation(x,i),count])
count+=1
p.sort()
for i in range(1,number+1):
print(song_names[p[i][1]])
```
```Python
e=input('Please enter The name of the song :')
f=int(input('Please enter the number of recommendations you want: '))
make_matrix_correlation(df,e,f)
```
## See you on other data science projects. Take care of yourselves:)