
System diagram
Data Collection
The system collects data from two primary sources:
- Clothing Data: Using RFID-RC522 sensor with a Raspberry Pi 3B+, the system reads NTAG213 tags attached to clothing items. Each scan records the item and timestamp.
- Music Data: Utilizing the Spotify API, the system fetches detailed track features including danceability, acousticness, energy, instrumentalness, valence, and more.

Schematic of the RPi to RC-522 sensor
Data Analysis and Clustering
The core of the StyleSync system lies in its data analysis and clustering approach:
- Data Normalization: Track features are normalized to ensure comparability. For instance, loudness is scaled to match the 0-1 range of other features.
- Feature Selection:Based on initial analysis, less relevant features like 'speechiness' and 'liveness' were dropped to focus on more impactful attributes.
- K-means Clustering: The system uses k-means clustering to group songs into distinct mood categories. The optimal number of clusters (k=4) was determined using the elbow method.

- Principal Component Analysis (PCA): To visualize the high-dimensional data, PCA was employed, revealing clear separation between the four identified clusters.

The four identified clusters correspond to distinct music moods:
- Cluster 0 (Study): High acousticness and instrumentalness, typically classical music.
- Cluster 1 (Happy): High valence, upbeat tracks.
- Cluster 2 (Chill): Moderate values across features, relaxed music.
- Cluster 3 (Energetic): High energy, often associated with running or workout playlists.
Cluster Mean Values Chart

Machine Learning Model
To predict the appropriate music mood based on clothing choices, the clustered data was exported to CSV files with their respective 'mood' labels.
Several classification models were tested, with the Random Forest Classifier proving most accurate.The model uses clothing data as input to predict the most suitable music mood cluster.Random Forest Confusion Matrix
Future Enhancements
- Incorporate more data sources (e.g., location, time of day) for more nuanced recommendations.
- Implement more sophisticated models to capture complex relationships between clothing and music preferences.
- Develop a more intuitive user interface for real-time music recommendations.
StyleSync demonstrates the potential of combining IoT, machine learning, and music streaming technologies to create a truly personalized user experience, bridging the gap between physical fashion choices and digital music preferences.