Recommender
Recommender Page
The recommender page (Home Page) provides the User Interface (UI) structure and process behind the recommendation system.
Recommender Page Documentation
access_tracks()
Method enables access to saved track information.
Returns:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
The dataframe containing all feature information of saved tracks |
Source code in src/recommender.py
105 106 107 108 109 110 111 112 113 114 | |
create_feature_weighting(maximum=12)
Creates a streamlit dropdown menu, providing a selection of features that the user can select to weight.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maximum |
int
|
The maximum number of features you can choose for weighting. |
12
|
Returns:
| Type | Description |
|---|---|
list
|
A list of selected feature names. |
Source code in src/recommender.py
179 180 181 182 183 184 185 186 187 188 189 190 191 | |
display_spotify_recommendations()
Method deals with displaying the Spotify recommendations in the form of Spotify iFrames for each recommendation.
This section is composed of two columns, with 30 recommendations split evenly between them creating a 15 x 2 table.
Source code in src/recommender.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
feature_def_section()
This method creates the features section in the Streamlit app.
Specifically, it creates the feature definitions drop down information.
Source code in src/recommender.py
14 15 16 17 18 19 20 21 22 23 24 25 26 | |
playlist_submission()
Method handles the process that follows the clicking of the submit button
The process is as follows: - The given playlist tracks are retrieved. - The tracks dataset is read in - Similarity is calculated - Streamlit session states are updated
Source code in src/recommender.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
playlist_to_df(playlist)
Method transforms playlist information in dictionary form to a playlist dataframe Args: playlist (dict): Playlist information in a dictionary, keys are features and values are a list.
Returns:
| Type | Description |
|---|---|
DataFrame
|
A playlist dataframe. |
Source code in src/recommender.py
141 142 143 144 145 146 147 148 149 150 | |
retrieve_feature_defs()
Method retrieves the feature definitions from the data/feature_def.txt file.
Returns:
| Type | Description |
|---|---|
str
|
The contents of the |
Source code in src/recommender.py
194 195 196 197 198 199 200 201 202 203 204 | |
retrieve_target_playlist(url, name)
This method gathers all the playlist song features and merges this data into the tracks dataset.
Note: credentials are stored using Streamlit secrets keeper
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url |
str
|
The url for the spotify playlist |
required |
name |
str
|
The name of the spotify playlist |
required |
Returns: playlist (DataFrame): The playlist features as a DataFrame
Source code in src/recommender.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
search_history_section()
This method creates the search history section of the Streamlit application.
This section provides a drop-down that displays the search history in the from playlist name | playlist url
Source code in src/recommender.py
29 30 31 32 33 34 35 36 37 38 39 40 | |
search_results_section()
This methods creates the search results section in the Streamlit app.
This can be broken down into two sub-sections. 1. Spotify Recommendations 2. The similarity visualization
Note, if no playlist or name is given, this section is replaced by a Please perform search first message
Source code in src/recommender.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
similarity_visualization()
This method creates the similarity visualization of the dataset tracks to the created dataset feature vector.
Returns:
| Type | Description |
|---|---|
Pyplot Figure
|
Figure for visualization by Streamlit |
Source code in src/recommender.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |