Prepare tracks for model endpoint
Build the ModelPrep class.
Use the class to prepare a list of tracks and their associated features for use in model prediction.
ModelPrep
ModelPrep ()
A class for preparing data for a Spotify recommendation model.
ModelPrep.load_scaler
ModelPrep.load_scaler ()
Loads the scaler object from S3.
ModelPrep.load_svd
ModelPrep.load_svd ()
Loads the SVD object from S3.
ModelPrep.load_tracks_data
ModelPrep.load_tracks_data ()
Loads the Spotify and Last.fm tracks data and merges them.
ModelPrep.load_genre_series
ModelPrep.load_genre_series ()
Loads the genre series data from S3.
ModelPrep.load_key_series
ModelPrep.load_key_series ()
Loads the key series data from S3.
ModelPrep.load_time_signature_series
ModelPrep.load_time_signature_series ()
Loads the time signature series data from S3.
ModelPrep.load_s3
ModelPrep.load_s3 ()
Loads all necessary data from S3.
ModelPrep.transform_features
ModelPrep.transform_features (constant)
Transforms the features of the prepped DataFrame.
Type | Details | |
---|---|---|
constant | float | The constant to add to ‘speechiness’, ‘acousticness’, and ‘instrumentalness’ before log-transforming. |
Returns | None |
ModelPrep.update_dataframe_with_prefix
ModelPrep.update_dataframe_with_prefix (current_dataframe, series, prefix)
Updates the DataFrame with a one-hot encoded series.
Type | Details | |
---|---|---|
current_dataframe | pandas.DataFrame | The DataFrame to update. |
series | pandas.Series | The series to one-hot encode. |
prefix | str | The prefix to add to the column names. |
Returns | pandas.DataFrame | The updated DataFrame. |
ModelPrep.prepare_final_frame
ModelPrep.prepare_final_frame ()
Prepares the final DataFrame for prediction.
ModelPrep.save_prepared_frame
ModelPrep.save_prepared_frame ()
Saves the prepared DataFrame to S3.