File size: 6,679 Bytes
5dbb8a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facdff9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a1093ca
facdff9
a1093ca
929d03f
facdff9
 
 
 
 
 
 
 
 
 
6fd7f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
---
dataset_info:
  features:
  - name: analysis_sample_rate
    dtype: int32
  - name: artist_7digitalid
    dtype: int32
  - name: artist_familiarity
    dtype: float64
  - name: artist_hotttnesss
    dtype: float64
  - name: artist_id
    dtype: string
  - name: artist_latitude
    dtype: float64
  - name: artist_location
    dtype: string
  - name: artist_longitude
    dtype: float64
  - name: artist_mbid
    dtype: string
  - name: artist_mbtags
    sequence: binary
  - name: artist_mbtags_count
    sequence: int64
  - name: artist_name
    dtype: string
  - name: artist_playmeid
    dtype: int32
  - name: artist_terms
    sequence: binary
  - name: artist_terms_freq
    sequence: float64
  - name: artist_terms_weight
    sequence: float64
  - name: audio_md5
    dtype: string
  - name: bars_confidence
    sequence: float64
  - name: bars_start
    sequence: float64
  - name: beats_confidence
    sequence: float64
  - name: beats_start
    sequence: float64
  - name: danceability
    dtype: float64
  - name: duration
    dtype: float64
  - name: end_of_fade_in
    dtype: float64
  - name: energy
    dtype: float64
  - name: key
    dtype: int32
  - name: key_confidence
    dtype: float64
  - name: loudness
    dtype: float64
  - name: mode
    dtype: int32
  - name: mode_confidence
    dtype: float64
  - name: num_songs
    dtype: int64
  - name: release
    dtype: string
  - name: release_7digitalid
    dtype: int32
  - name: sections_confidence
    sequence: float64
  - name: sections_start
    sequence: float64
  - name: segments_confidence
    sequence: float64
  - name: segments_loudness_max
    sequence: float64
  - name: segments_loudness_max_time
    sequence: float64
  - name: segments_loudness_start
    sequence: float64
  - name: segments_pitches
    sequence:
      sequence: float64
  - name: segments_start
    sequence: float64
  - name: segments_timbre
    sequence:
      sequence: float64
  - name: similar_artists
    sequence: binary
  - name: song_hotttnesss
    dtype: float64
  - name: song_id
    dtype: string
  - name: start_of_fade_out
    dtype: float64
  - name: tatums_confidence
    sequence: float64
  - name: tatums_start
    sequence: float64
  - name: tempo
    dtype: float64
  - name: time_signature
    dtype: int32
  - name: time_signature_confidence
    dtype: float64
  - name: title
    dtype: string
  - name: track_7digitalid
    dtype: int32
  - name: track_id
    dtype: string
  - name: year
    dtype: int32
  splits:
  - name: train
    num_bytes: 2365768621
    num_examples: 10000
  download_size: 1041881893
  dataset_size: 2365768621
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
---

# Million Song Subset (Processed Version)

## Overview
This dataset is a structured extraction of the [Million Song Subset](http://millionsongdataset.com/pages/getting-dataset/#subset), derived from HDF5 files into a tabular format for easier accessibility and analysis.

## Source
- Original dataset: **Million Song Dataset** (LabROSA, Columbia University & The Echo Nest)
- Subset used: **Million Song Subset** (10,000 songs)
- URL: [http://millionsongdataset.com](http://millionsongdataset.com)

## Processing Steps
1. **Extraction**: Used `hdf5_getters.py` to retrieve all available fields.
2. **Parallel Processing**: Optimized extraction with `ProcessPoolExecutor` for speed.
3. **Conversion**: Structured into a Pandas DataFrame.
4. **Storage**: Saved as a Parquet file for efficient usage.

## Format
- **Columns**: Contains all available attributes from the original dataset, including artist metadata, song features, and audio analysis.
- **File Format**: Parquet (optimized for efficient querying & storage).

## Usage
- Load the dataset with Datasets:
  ```python
  from datasets import load_dataset  
  ds = load_dataset("trojblue/million-song-subset")
  ```
- Explore and analyze various musical attributes easily.

## License
- **Original License**: Refer to the [Million Song Dataset license](http://millionsongdataset.com/pages/terms-of-use/)
- **Processed Version**: Shared for research and non-commercial purposes.

For more details, visit the [Million Song Dataset website](http://millionsongdataset.com).


## Appendix: Processing Code

The dataset was converted using the following snippet:

```python
import os
import unibox as ub
import pandas as pd
import numpy as np
import h5py
from tqdm import tqdm
from concurrent.futures import ProcessPoolExecutor

# https://github.com/tbertinmahieux/MSongsDB/blob/0c276e289606d5bd6f3991f713e7e9b1d4384e44/PythonSrc/hdf5_getters.py
import hdf5_getters

# Define dataset path
dataset_path = "/lv0/yada/dataproc5/data/MillionSongSubset"

# Function to extract all available fields from an HDF5 file
def extract_song_data(file_path):
    """Extracts all available fields from an HDF5 song file using hdf5_getters."""
    song_data = {}

    try:
        with hdf5_getters.open_h5_file_read(file_path) as h5:
            # Get all getter functions from hdf5_getters
            getters = [func for func in dir(hdf5_getters) if func.startswith("get_")]

            for getter in getters:
                try:
                    # Dynamically call each getter function
                    value = getattr(hdf5_getters, getter)(h5)

                    # Optimize conversions
                    if isinstance(value, np.ndarray):
                        value = value.tolist()
                    elif isinstance(value, bytes):
                        value = value.decode()

                    # Store in dictionary with a cleaned-up key name
                    song_data[getter[4:]] = value

                except Exception:
                    continue  # Skip errors but don't slow down

    except Exception as e:
        print(f"Error processing {file_path}: {e}")
    
    return song_data

# Function to process multiple files in parallel
def process_files_in_parallel(h5_files, num_workers=8):
    """Processes multiple .h5 files in parallel."""
    all_songs = []

    with ProcessPoolExecutor(max_workers=num_workers) as executor:
        for song_data in tqdm(executor.map(extract_song_data, h5_files), total=len(h5_files)):
            if song_data:
                all_songs.append(song_data)
    
    return all_songs

# Find all .h5 files
h5_files = [os.path.join(root, file) for root, _, files in os.walk(dataset_path) for file in files if file.endswith(".h5")]

# Process files in parallel
all_songs = process_files_in_parallel(h5_files, num_workers=24)

# Convert to Pandas DataFrame
df = pd.DataFrame(all_songs)

ub.saves(df, "hf://trojblue/million-song-subset", private=False)
```