text_plain_output_1.png image_output_1.png
from deepface import DeepFace

import cv2

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

index = 0
def emotions(image):
    img = cv2.imread(image)
    demography = DeepFace.analyze(image, actions=['emotion'], enforce_detection=False, detector_backend='retinaface')
    return demography
emotion = emotions(image='/kaggle/input/newpic/2Q__ (2)_face.png')
dominant_emotion = emotion[index]['dominant_emotion']

music_dataset = pd.read_csv('/kaggle/input/kaggledataupdated/KaggleData_updated.csv')

music_dataset.shape

music_update = music_dataset.set_index('id')

music_update['artists'] = music_update['artists'].str.strip("[]'")

music_update.isna().sum()

music_update.duplicated().sum()

music_update = music_update.drop_duplicates()

music_update.duplicated().value_counts()

nameColumn = music_update.pop('name')
artistColumn = music_update.pop('artists')

music_update.insert(0, 'name', nameColumn)
music_update.insert(1, 'artist', artistColumn)

music_update.drop('release_date', axis=1)

music_updated = music_update

Trends = music_updated[['acousticness', 'danceability', 'energy', 'instrumentalness', 'liveness', 'valence', 'year']]
sound_features = ['acousticness', 'danceability', 'energy', 'instrumentalness', 'liveness', 'valence']

def get_decade(year):
    period = int(year / 10) * 10
    decade = '{}s'.format(period)
    return decade
Trends['decade'] = Trends['year'].apply(get_decade)
Trends_updated = Trends.groupby('decade')[sound_features].mean()
Trends_updated

plt.figure(figsize=(12, 8))
sns.heatmap(Trends_updated.corr(), annot=True, square=True)