This guide outlines the preprocessing steps needed to prepare the DEAM dataset for training a mood classification neural network. It is optimized to be used with AI-assisted coding tools like Cursor.
Create a training-ready dataset by merging DEAM's audio features with averaged valence/arousal annotations, and optionally generate discrete mood labels for classification.
- Source:
features/audio_features/ - Action:
- Load all relevant CSVs.
- Merge them into a single
DataFrameusingsong_idor consistent indexing. - Drop any duplicate or NaN rows.
- Source:
annotations/averaged_annotations/song_level/static_annotations_averaged_songs_*.csv - Action:
- Extract
song_id,valence_mean, andarousal_meancolumns. - This will serve as your target label(s).
- Extract
- Join the features
DataFramewith the labels usingsong_idorfilename. - Drop rows with missing or misaligned values.
- Create a new column
mood_classusing this logic:
def mood_label(valence, arousal):
if valence >= 0.5 and arousal >= 0.5:
return "Energetic"
elif valence >= 0.5 and arousal < 0.5:
return "Chill"
elif valence < 0.5 and arousal >= 0.5:
return "Tense"
else:
return "Melancholic"- Output file:
processed_dataset.csv - Columns should include:
- Feature columns (e.g.
tempo,mfcc_1,rms, ...) valence,arousal- (Optional)
mood_class
- Feature columns (e.g.
| tempo | mfcc_1 | ... | valence | arousal | mood_class |
|---|---|---|---|---|---|
| 120.0 | 0.123 | ... | 0.71 | 0.62 | Energetic |
- Normalize or standardize features if needed during model training.
- Save as
.csvor.parquetfor fast loading later. - Ensure reproducibility by setting a random seed for any data splits.