A graph-based music recommendation system that finds similar songs based on audio features and creates personalized Spotify playlists.
Originally developed as a collaborative project, then extended independently with additional optimizations and features.
This application analyzes Spotify song data to find tracks with similar audio characteristics. When you select a song, the system:
- Calculates similarity scores against thousands of songs using audio features
- Returns the top 25 most similar tracks with similarity percentages
- Automatically creates a Spotify playlist with your recommendations
- Visualizes the song similarity network as an interactive graph
- Smart Song Search: Search by song name or artist with auto-suggestions
- Audio-Based Matching: Uses 11 audio features for accurate similarity scoring
- Spotify Integration: Creates public playlists directly in your Spotify account
- Network Visualization: Interactive graph showing song relationships
- Multi-Song Mode: Find songs similar to two tracks simultaneously
Audio features are normalized using MinMaxScaler, then songs are compared using weighted Euclidean distance across 11 Spotify audio features. The result is converted to a similarity score between 0% (completely different) and 100% (identical features).
| Feature | Description |
|---|---|
| Danceability | How suitable for dancing (0.0 - 1.0) |
| Energy | Intensity and activity level (0.0 - 1.0) |
| Valence | Musical positiveness/happiness (0.0 - 1.0) |
| Tempo | Beats per minute (BPM) |
| Acousticness | Confidence the track is acoustic |
| Speechiness | Presence of spoken words |
| Instrumentalness | Likelihood of no vocals |
| Liveness | Probability of live recording |
| Loudness | Overall volume in decibels |
| Key | Musical key (0-11) |
| Mode | Major (1) or minor (0) |
- Each song is a vertex containing metadata and audio features
- Edges connect songs with similarity scores above 90%
- The graph enables efficient traversal and relationship visualization
- Python 3.9+
- Spotify Developer Account (for API access)
- Clone the repository:
git clone https://github.com/oliverbisbee/MelodyMap
cd MelodyMap- Install dependencies:
pip install spotipy networkx matplotlib scikit-learn- Configure Spotify API credentials in
main.py:
SPOTIFY_CLIENT_ID = "your_client_id"
SPOTIFY_CLIENT_SECRET = "your_client_secret"
SPOTIFY_REDIRECT_URI = "http://127.0.0.1:8080"- Run the application:
python main.py- Launch the GUI with
python main.py - Type a song name or artist in the search box
- Select a song from the suggestions
- Click "Select Song" to get recommendations
- View similarity scores and the generated playlist link
- Double-click the playlist link to open in Spotify
- Run
python "multiple song.py" - Enter two song names when prompted
- View songs that are similar to both tracks
- See the dual-similarity visualization
MelodyMap/
├── main.py # Main application with GUI
├── multiple song.py # Two-song similarity comparison
├── ex3_visualization.py # Alternate visualization module
├── spotify_songs.csv # Dataset (~32,000 songs)
└── spotify_data/
└── readme.md # Dataset documentation
The dataset contains approximately 32,000 Spotify songs with:
- Track metadata (name, artist, album)
- Audio features extracted via Spotify API
- Popularity scores
Source: TidyTuesday Spotify Dataset
The network graph displays:
- Red node: Your selected song
- Green nodes: Similar songs (90%+ similarity)
- Edges: Connections between highly similar tracks
spotipy- Spotify API wrapperscikit-learn- Feature normalization and similarity computationnetworkx- Graph data structuresmatplotlib- Visualizationtkinter- GUI framework (included with Python)
Oliver Bisbee, Mustafa Maj, Rayyan Hussain, Mahir Asif Chowdhury