SlideShare a Scribd company logo
1 of 14
Download to read offline
Funk ou Bossa Nova?
Rafael Fantini da Costa | Data Scientist
Usando Machine Learning para
descobrir o gênero de uma
música
Ideia:
Startup para
classificar gênero
de músicas
1. Defina (bem)
o problema
Do contrário você pode
encontrar a resposta certa
para o problema errado
Dada a letra de uma
música, classificar o
gênero musical
como Funk, Gospel,
Bossa Nova ou
Sertanejo
2. Escolha a
métrica de
avaliação
% de acertos é um bom
começo, mas muitas vezes
não reflete a necessidade
(fraudes, por exemplo)
% de acertos
(número de acertos
/ número total)
200 acertos em 250 letras
= 80%
3. Colete dados
de treinamento
Quanto mais difícil o
problema, mais dados
você vai precisar.
1000 letras para
cada gênero
Obtido por meio de
web scraping no site
letras.mus.br
É a flauta envolvente que mexe com...
De quem tá presente
As novinha saliente
Fica loucona e se joga pra gente
Aí eu falei assim pra ela
(Aí eu falei assim pra ela)
Vai com o bum bum, tam tam
Vem com o bum bum, tam tam tam
Vai, mexe o bum bum, tam tam
Vem, desce o bum bum, tam tam tam
Por céus e mares eu andei
Vi um poeta e vi um rei
Na esperança de saber o que é o amor
Ninguém sabia me dizer
E eu já queria até morrer
Quando um velhinho com uma flor...
O amor é o carinho
É o espinho que não se vê em cada...
É a vida quando
Chega sangrando
Aberta em pétalas de amor
X
4a. Transformar
texto em algo
calculável:
Bag of Words
Quebramos as letras em
termos (tokenização) e
calculamos as frequências
Termo Frequência
ô 1
tu 1
tão 2
... ...
rabetão 1
"Ô tu tá tão, tão
Linda com esse rabetão"
- MC Lan
rabetão louvor ... termo[n]
letra1 19 0 ... 3
letra2 0 8 ... 2
letra3 0 0 ... 4
... ... ... ... ...
letra[m] 9 0 ... 1
gênero
Funk
Gospel
Sertanejo
...
?
X y
4b. Treinar um
classificador
utilizando X e y
Naive Bayes,
Regressão Logística,
Support Vector Machine,
etc
Extração de características
-> Treinar classificador
Letras categorizadas
Pré-processamento[*]
[*] tokenizar, lowercase,
remover pontuação, etc
Obrigado! Python
scikit-learn machine learning
nltk proc. de linguagem natural
www.continuum.io/downloads
Java
Spark ML machine learning
Mallet proc. de linguagem natural
github.com/fanta-mnix
@fanta em thetechcafe.slack.com
tu 6.47
tá 5.99
baile 5.34
novinha 5.14
2x 5.06
bonde 4.61
mc 4.54
favela 4.49
bunda 4.40
então 4.35
garota 4.16
funk 4.12
hoje 4.11
elas 4.10
ta 3.93
pro 3.88
nós 3.83
vários 3.70
vai 3.68
quando eu 3.64
ela 3.54
mina 3.50
maldade 3.49
mano 3.44
caô 3.42
desce 3.40
eles 3.33
louco 3.32
na 3.32
joga 3.31
puta 3.27
moleque 3.26
senta 3.23
rebola 3.18
geral 3.13
bumbum 3.12
pra mim 3.05
pega 3.03
pau 3.03
mente 3.03
nóis 2.97
com 2.94
deus 11.75
senhor 9.76
jesus 9.70
ele 6.35
mãe 4.57
de deus 4.50
tua 4.41
ti 4.40
glória 4.35
teu 3.77
graça 3.57
pai 3.52
mim 3.44
cruz 3.26
presença 3.24
não há 3.21
estou 3.20
tu és 3.08
adorar 3.05
de jesus 3.02
do senhor 2.84
lugar 2.81
espírito 2.80
teu amor 2.80
impossível 2.77
está 2.77
céu 2.72
com amor 2.67
obra 2.63
benção 2.61
fé 2.60
minha mãe 2.58
caminhar 2.58
por mim 2.57
que deus 2.55
santo 2.54
sobre 2.48
feridas 2.47
és 2.47
espírito santo 2.46
cristo 2.44
milagre 2.43
você 7.49
saudade 5.57
seu 5.48
aqui 5.18
gente 5.15
paixão 5.07
que gente 4.47
tô 4.39
eu 4.27
pra 4.15
destino 4.08
sorriso 3.97
cê 3.97
ai ai 3.96
te 3.90
boca 3.74
nosso 3.73
viola 3.72
te esquecer 3.64
estrada 3.59
apaixonado 3.50
trem 3.49
beijo 3.45
cerveja 3.41
jeito 3.37
eu mais 3.30
amor 3.29
tempo 3.28
fora 3.24
pessoa 3.20
chorei 3.18
amar 3.18
de tudo 3.15
solidão 3.10
ex 3.09
frio 3.08
não vai 3.05
anos 3.03
chorando 3.02
meu corpo 3.00
galera 2.99
sertão 2.92
samba 7.51
mar 5.66
de 4.90
que 4.84
meu amor 4.44
sol 4.28
lá 3.63
beleza 3.59
tristeza 3.54
xangô 3.50
há 3.47
prá 3.41
rosa 3.40
cantar 3.35
ninguém 3.29
tarde 3.08
adeus 3.08
ah 3.06
triste 3.00
coisa 2.98
isto 2.95
carnaval 2.92
lhe 2.91
poesia 2.88
ni 2.86
do mar 2.83
num 2.76
ilusão 2.75
la 2.74
gente que 2.72
feliz 2.69
all 2.62
luar 2.60
inda 2.59
moço 2.56
ouve 2.55
porém 2.54
depois 2.49
bahia 2.48
oi 2.47
que vou 2.45
escuro 2.45

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Funk ou Bossa Nova? Usando Machine Learning para descobrir o gênero de uma música

  • 1. Funk ou Bossa Nova? Rafael Fantini da Costa | Data Scientist Usando Machine Learning para descobrir o gênero de uma música
  • 3. 1. Defina (bem) o problema Do contrário você pode encontrar a resposta certa para o problema errado Dada a letra de uma música, classificar o gênero musical como Funk, Gospel, Bossa Nova ou Sertanejo
  • 4. 2. Escolha a métrica de avaliação % de acertos é um bom começo, mas muitas vezes não reflete a necessidade (fraudes, por exemplo) % de acertos (número de acertos / número total) 200 acertos em 250 letras = 80%
  • 5. 3. Colete dados de treinamento Quanto mais difícil o problema, mais dados você vai precisar. 1000 letras para cada gênero Obtido por meio de web scraping no site letras.mus.br
  • 6. É a flauta envolvente que mexe com... De quem tá presente As novinha saliente Fica loucona e se joga pra gente Aí eu falei assim pra ela (Aí eu falei assim pra ela) Vai com o bum bum, tam tam Vem com o bum bum, tam tam tam Vai, mexe o bum bum, tam tam Vem, desce o bum bum, tam tam tam Por céus e mares eu andei Vi um poeta e vi um rei Na esperança de saber o que é o amor Ninguém sabia me dizer E eu já queria até morrer Quando um velhinho com uma flor... O amor é o carinho É o espinho que não se vê em cada... É a vida quando Chega sangrando Aberta em pétalas de amor X
  • 7. 4a. Transformar texto em algo calculável: Bag of Words Quebramos as letras em termos (tokenização) e calculamos as frequências Termo Frequência ô 1 tu 1 tão 2 ... ... rabetão 1 "Ô tu tá tão, tão Linda com esse rabetão" - MC Lan
  • 8. rabetão louvor ... termo[n] letra1 19 0 ... 3 letra2 0 8 ... 2 letra3 0 0 ... 4 ... ... ... ... ... letra[m] 9 0 ... 1 gênero Funk Gospel Sertanejo ... ? X y
  • 9. 4b. Treinar um classificador utilizando X e y Naive Bayes, Regressão Logística, Support Vector Machine, etc Extração de características -> Treinar classificador Letras categorizadas Pré-processamento[*] [*] tokenizar, lowercase, remover pontuação, etc
  • 10. Obrigado! Python scikit-learn machine learning nltk proc. de linguagem natural www.continuum.io/downloads Java Spark ML machine learning Mallet proc. de linguagem natural github.com/fanta-mnix @fanta em thetechcafe.slack.com
  • 11. tu 6.47 tá 5.99 baile 5.34 novinha 5.14 2x 5.06 bonde 4.61 mc 4.54 favela 4.49 bunda 4.40 então 4.35 garota 4.16 funk 4.12 hoje 4.11 elas 4.10 ta 3.93 pro 3.88 nós 3.83 vários 3.70 vai 3.68 quando eu 3.64 ela 3.54 mina 3.50 maldade 3.49 mano 3.44 caô 3.42 desce 3.40 eles 3.33 louco 3.32 na 3.32 joga 3.31 puta 3.27 moleque 3.26 senta 3.23 rebola 3.18 geral 3.13 bumbum 3.12 pra mim 3.05 pega 3.03 pau 3.03 mente 3.03 nóis 2.97 com 2.94
  • 12. deus 11.75 senhor 9.76 jesus 9.70 ele 6.35 mãe 4.57 de deus 4.50 tua 4.41 ti 4.40 glória 4.35 teu 3.77 graça 3.57 pai 3.52 mim 3.44 cruz 3.26 presença 3.24 não há 3.21 estou 3.20 tu és 3.08 adorar 3.05 de jesus 3.02 do senhor 2.84 lugar 2.81 espírito 2.80 teu amor 2.80 impossível 2.77 está 2.77 céu 2.72 com amor 2.67 obra 2.63 benção 2.61 fé 2.60 minha mãe 2.58 caminhar 2.58 por mim 2.57 que deus 2.55 santo 2.54 sobre 2.48 feridas 2.47 és 2.47 espírito santo 2.46 cristo 2.44 milagre 2.43
  • 13. você 7.49 saudade 5.57 seu 5.48 aqui 5.18 gente 5.15 paixão 5.07 que gente 4.47 tô 4.39 eu 4.27 pra 4.15 destino 4.08 sorriso 3.97 cê 3.97 ai ai 3.96 te 3.90 boca 3.74 nosso 3.73 viola 3.72 te esquecer 3.64 estrada 3.59 apaixonado 3.50 trem 3.49 beijo 3.45 cerveja 3.41 jeito 3.37 eu mais 3.30 amor 3.29 tempo 3.28 fora 3.24 pessoa 3.20 chorei 3.18 amar 3.18 de tudo 3.15 solidão 3.10 ex 3.09 frio 3.08 não vai 3.05 anos 3.03 chorando 3.02 meu corpo 3.00 galera 2.99 sertão 2.92
  • 14. samba 7.51 mar 5.66 de 4.90 que 4.84 meu amor 4.44 sol 4.28 lá 3.63 beleza 3.59 tristeza 3.54 xangô 3.50 há 3.47 prá 3.41 rosa 3.40 cantar 3.35 ninguém 3.29 tarde 3.08 adeus 3.08 ah 3.06 triste 3.00 coisa 2.98 isto 2.95 carnaval 2.92 lhe 2.91 poesia 2.88 ni 2.86 do mar 2.83 num 2.76 ilusão 2.75 la 2.74 gente que 2.72 feliz 2.69 all 2.62 luar 2.60 inda 2.59 moço 2.56 ouve 2.55 porém 2.54 depois 2.49 bahia 2.48 oi 2.47 que vou 2.45 escuro 2.45