## ANTES DE USAR
# Para criar data/movies.csv
import_data("natalie_portman")
## Loading required package: rvest
## Loading required package: xml2
##
## Attaching package: 'rvest'
## The following object is masked from 'package:purrr':
##
## pluck
## The following object is masked from 'package:readr':
##
## guess_encoding
## Warning: NAs introduzidos por coerção
Usando o site do Rotten Tomatoes, que é uma plataforma com informações sobre produções audiovisuais extraimos as informações dos filmes da atriz Natalie Portman, para realizar analises sobre bilheteria e avaliação de cada um.
filmes = read_imported_data()
Agora, podemos agrupar os filmes da atriz para melhor observá-los. Primeiro precisamos normalizar as variáveis, pois alguns filmes possuem bilheterias muito altas quando comparados a outros, dificultando a visualização.
m_transformado = filmes %>%
mutate(aval_scaled = as.vector(scale(avaliacao)),
bilheteria_log_scaled = as.vector(scale(log10(bilheteria))))
m_transformado %>%
select(aval_scaled, bilheteria_log_scaled) %>%
summary()
## aval_scaled bilheteria_log_scaled
## Min. :-1.8731 Min. :-2.20322
## 1st Qu.:-0.8516 1st Qu.:-0.34658
## Median : 0.1167 Median :-0.04246
## Mean : 0.0000 Mean : 0.00000
## 3rd Qu.: 0.8331 3rd Qu.: 0.55795
## Max. : 1.2576 Max. : 1.63771
Para continuar o agrupamento, vamos utilizar o algoritmo k-means, mas antes disso, devemos identificar a melhor quantidade de grupos para dividir os filmes de Natalie e passar essa informação para o algoritmo.
plot_clusgap = function(clusgap, title = "Gap Statistic calculation results") {
require("ggplot2")
gstab = data.frame(clusgap$Tab, k = 1:nrow(clusgap$Tab))
p = ggplot(gstab, aes(k, gap)) + geom_line() + geom_point(size = 5)
p = p + geom_errorbar(aes(ymax = gap + SE.sim, ymin = gap - SE.sim), width = .2)
p = p + ggtitle(title)
return(p)
}
gaps <- m_transformado %>%
select(ano, bilheteria) %>%
clusGap(FUN = kmeans, nstart = 20, K.max = 8, B = 200)
plot_clusgap(gaps)
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x,
## x$y, : font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
Usando o GAP statistic conseguimos observar que o melhor valor será de 5 grupos.
set.seed(12345)
n_clusters = 5
# O agrupamento de fato:
cluster = m_transformado %>%
select(bilheteria_log_scaled, aval_scaled) %>%
kmeans(centers = n_clusters, nstart = 20)
agrupado = cluster %>%
augment(m_transformado)
ggscatter(agrupado, x="avaliacao", y="bilheteria", color=".cluster")+
stat_chull(aes(fill = .cluster), alpha=0.3, geom="polygon")+
xlab("Avaliação")+
ylab("Bilheteria")
A atriz interpretando Padmé
Filmes: “Star Wars: Episode I - The Phantom Menace”(1999), “Star Wars: Episode II - Attack of the Clones”(2002), “Thor”(2011), “Thor: The Dark World”(2013), “Black Swan”(2010).
“I’t was perfect.” - Nina, “The Black Swan”.
Esse grupo é composto pelos filmes com maior bilheteria da atriz. São os que foram bem aceitos pelo público, com temas mais populares, como heróis e alienigenas. O filme com maior bilheteria da carreira de Natalie é o primeiro filme de Star Wars. Apesar disso, não são os melhores avaliados, há apenas um filme que possui uma nota significativamente alta.
Natalie em “Jackie”(2016)
Filmes:“Garden State”(2004), “Annihilation”(2018),“Jackie”(2016), “Paris Je T’aime”(2007).
Objects and artifacts last far longer than people, and they represent important ideas in history, identity, beauty. -Jackie, “Jackie”.
Esse grupo possui os filmes melhor avaliados de sua carreira, com um empate entre Jackie, onde ela interpreta Jacqueline Kennedy, esposa do ex presidente americano John F. Kennedy e Annihilation, um filme de ficção cientifica onde interpreta uma bióloga, ambos recentes e com nota de 87/100. No filme Annihilation podemos ver um tema recorrente de sua carreira reaparecer: ALIENS!! O grupo pode não possuir os filmes mais conhecidos do público, mas demonstram uma grande capacidade de atuação da atriz e foram bem aclamados pelos críticos.
Natalie interpretando Jane Hammond em “Jane Got a Gun”(2016)
Filmes: “Jane Got a Gun”(2016), “New York, I Love You”(2009).
If them bullets don’t kill you, and this storm you somehow brought upon us don’t kill you, goes without saying… I will kill you. - Jane Hammond, “Jane Got a Gun”.
Nesse agrupamento vemos que alguns filmes da Natalie não tiveram uma bilheteria muito alta, tão pouco uma boa avaliação. O filme New York, I Love You é um compilado de curtas de comédia romantica, dirigido por vários diretores. Os filmes de comédia romantica geralmente não tem uma boa avaliação nos sites como Rotten Tomatoes ou IMDB, mas são filmes leves e descontraidos, perfeito para relaxar e devanear um pouco. Já o filme Jane Got a Gun tem uma pegada totalmente diferente e é um filme de faroeste, onde a personagem luta contra uma gangue de assassinos para proteger seu marido. Ao longo da análise, fica ainda mais evidente que a maioria das personagens da atriz são mulheres fortes e determinadas.
A atriz em “The Other Boleyn Girl”(2008)
Filmes: “No Strings Attached”(2011), “The Other Boleyn Girl”(2008), “Mr. Magorium’s Wonder Emporium”(2007), “Your Highness”(2011).
Younger than me, more beautiful than me, married before me. I’m eclipsed! I’m the other Boleyn girl. - Anne Boleyn, “The Other Boleyn Girl”.
Curiosamente, dois dos quatro filmes do grupo possuem o tema “realeza” em comum, e outros dois foram lançados no mesmo ano(2011). Esse grupo é o famoso “não fede nem cheira” e tem produções com baixa bilheteria e notas fracas de avaliação, mas não chegam a ser tão baixas quanto as notas do grupo 3. Os filmes são um pouco mais conhecidos, principalmente The Other Boleyn Girl e No Strings Attached, já que ambos já passaram na TV. Apesar da metade se tratar de realeza, os filmes tem estilos muito diferentes, The Other Boleyn Girl é um drama cruel e verdadeiro, enquanto No Strings Attached é uma comédia romantica clichê e piegas.
Natalie em “Closer”(2004)
Filmes: “V for Vendetta”(2006), “Closer”(2004), “Zoolander”(2001), “The Darjeeling Limited”(2007), “Brothers”(2009).
Where is this love? I can’t see it, I can’t touch it. I can’t feel it. I can hear it. I can hear some words, but I can’t do anything with your easy words. - Alice, “Closer”.
O grupo 5 possui uma avaliação mediana, baixa bilheteria e alguns dos filmes mais conhecidos de Natalie: V for Vendetta e Closer. Eles foram trabalhos decisivos na carreira dela, pois com Closer a atriz ganhou o Globo de Ouro como melhor atriz coadjuvante. V for Vendetta é um filme relativamente popular, que trata sobre a luta em busca de liberdade em um governo fascista, já Closer é um drama sobre relacionamentos em Londres. O filme The Darjeeling Limited possui uma paleta de cores incrível e Zoolander é um filme de comédia americano. Esse grupo tem produções com tematicas pesadas e intensas e filmes mais leves, mas em geral devem agradar uma grande quantidade de pessoas.
p <- plot_ly(agrupado, x = ~avaliacao,
y = ~bilheteria,
color=~.cluster,
text = ~paste('Filme: ', filme,
"\nAvalicao: ", avaliacao,
"\nBilheteria: ", bilheteria,
"\nAno:", ano),
size = 3,
alpha = .8) %>%
layout(title = "Grupos",
xaxis = list(title = "Avaliação"),
yaxis = list(title = "Bilheteria"))
p
## No trace type specified:
## Based on info supplied, a 'scatter' trace seems appropriate.
## Read more about this trace type -> https://plot.ly/r/reference/#scatter
## No scatter mode specifed:
## Setting the mode to markers
## Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode