O que é CORRELAÇÃO e como analisar os Gráficos
Summary
TLDRIn this informative video, creator Jefferson explains the concept of correlation in data science, emphasizing its importance in predictive modeling and machine learning. He illustrates how to measure and interpret the strength and direction of correlations between variables using the correlation coefficient, ranging from -1 to 1. Through examples and visual aids like scatter plots and heat maps, viewers learn to identify weak, strong, and perfect correlations, and understand their significance in building intelligent models.
Takeaways
- 📊 Correlation is a vital concept in data science, measuring the relationship between two variables.
- 🔢 The correlation is quantified by a coefficient that ranges from -1 to 1, indicating the strength and direction of the relationship.
- 📈 A value close to 1 suggests a strong positive correlation, while a value near -1 indicates a strong negative correlation.
- ↔️ A correlation coefficient of exactly 1 or -1 represents a perfect positive or negative correlation, respectively.
- ➡️ As the script explains, a correlation of around 0 implies no correlation or a null relationship between variables.
- 📈 The script uses scatter plots to visually demonstrate the correlation between variables, such as the relationship between car age and value.
- 🚗 An example provided shows a positive correlation between car age and its value, indicating that newer cars have higher values.
- 🔍 The script also illustrates a negative correlation, such as between car engine size (cylinders) and fuel consumption, where larger engines tend to consume more fuel.
- 📊 The Hit map is introduced as a visual tool to interpret correlation coefficients, showing the strength of relationships through color gradients.
- 📉 The diagonal of the Hit map always shows a correlation of 1, representing the relationship of a variable with itself.
- 🔑 Understanding correlation is crucial for predictive modeling in machine learning and artificial intelligence, as it helps in assigning weights and metrics to variables.
Q & A
What is the main topic of the video script?
-The main topic of the video script is explaining the concept of correlation in data science, its importance, and how to interpret it through graphs.
Who is the creator of the channel mentioned in the script?
-The creator of the channel is Jefferson.
What is the purpose of the correlation coefficient in data science?
-The correlation coefficient is used to measure the relationship between two variables, indicating the strength and direction of the correlation.
What does a correlation coefficient value close to 1 or -1 indicate?
-A correlation coefficient value close to 1 indicates a strong positive correlation, while a value close to -1 indicates a strong negative correlation.
What is the significance of a correlation coefficient value of exactly 1 or -1?
-A correlation coefficient of exactly 1 indicates a perfect positive correlation, while a value of exactly -1 indicates a perfect negative correlation.
What does a correlation coefficient value near 0 represent?
-A correlation coefficient value near 0 represents no correlation or a null correlation between the variables.
How can one visualize the correlation between two variables using a scatter plot?
-In a scatter plot, the correlation between two variables can be visualized by observing the direction and slope of the line formed by the plotted points. A positive correlation will have an upward slope, while a negative correlation will have a downward slope.
What is a hit map graph and how is it used in the context of the script?
-A hit map graph is a visual representation that shows the correlation coefficients of variables in a matrix format, with colors indicating the strength of the correlation. It is used to quickly identify strong and weak correlations between variables.
What is the significance of correlation in predictive modeling and machine learning?
-Correlation is significant in predictive modeling and machine learning because it helps algorithms identify which variables are related to each other and should be given more weight in the model's mathematical function.
How does the script suggest to determine if a correlation is strong or weak?
-The script suggests using a scatter plot to visually determine if a correlation is strong or weak, and also mentions that a correlation coefficient above 0.6 is considered strong, above 0.8 is very strong, and at 1 is perfect.
What is the role of the correlation coefficient in exploratory data analysis?
-In exploratory data analysis, the correlation coefficient helps in identifying relationships between variables, which can be crucial for understanding data patterns and making informed decisions in further analysis.
Outlines
📊 Introduction to Correlation in Data Science
In this introductory segment, the speaker, Jefferson, creator of the channel, explains the concept of correlation in data science. He discusses the importance of understanding how variables relate to one another, whether one variable's increase leads to another's decrease or vice versa. The speaker introduces the correlation coefficient, a numerical value ranging from -1 to 1, to measure the strength and direction of the relationship between variables. A value close to 1 indicates a strong positive correlation, while a value close to -1 indicates a strong negative correlation. The speaker also mentions that a value near zero suggests no correlation. He uses graphical illustrations to help viewers understand these concepts better and promises to demonstrate how to identify and interpret correlations through graphs in the subsequent parts of the video.
📈 Understanding and Visualizing Positive and Negative Correlations
This paragraph delves deeper into the concept of positive and negative correlations, providing examples and visual explanations. The speaker explains that a strong positive correlation is indicated when the correlation coefficient is above 0.6, with 0.8 and above being considered very strong, and a perfect correlation being represented by the value 1. He uses scatter plots to illustrate the correlation between car age and its value, showing a positive correlation as newer cars have higher values. Conversely, a negative correlation is demonstrated using cylinders and car fuel consumption per liter, where an increase in engine power leads to a decrease in fuel efficiency. The speaker emphasizes the importance of visual representation through graphs for easy interpretation of correlation strength and direction.
📉 Evaluating Correlation Strength with Heat Maps and Hit Maps
In this segment, the speaker discusses how to evaluate the strength of correlations using heat maps and hit maps. He explains that these graphical tools can visually represent the correlation coefficients, making it easier to identify strong and weak correlations at a glance. The speaker provides examples of how to interpret these maps, pointing out that the diagonal of the hit map always shows a correlation of 1, as it represents the relationship of a variable with itself. He also demonstrates how to find the correlation between different variables, such as between car age and cylinders, and how to understand the color coding in heat maps to quickly assess the strength of correlations. The speaker concludes by emphasizing the importance of correlation in predictive modeling and machine learning, as it helps algorithms assign weights and metrics based on the relationships between variables.
Mindmap
Keywords
💡Correlation
💡Coefficient of Correlation
💡Data Science
💡Scatter Plot
💡Positive Correlation
💡Negative Correlation
💡Machine Learning
💡Heatmap
💡Data Frame
💡Correlation Coefficient
💡Exploratory Data Analysis
Highlights
Correlation is a crucial concept in data science, measuring the relationship between variables.
The video explains what correlation is, its purpose, and how to interpret it through graphs.
Correlation is identified through a coefficient that ranges from -1 to 1, indicating the strength and direction of the relationship.
A value close to 1 signifies a strong positive correlation, while a value near -1 indicates a strong negative correlation.
A correlation coefficient of exactly 1 or -1 denotes a perfect positive or negative correlation, respectively.
Scatter plots are used to visually assess the correlation between two variables.
A flat line in a scatter plot suggests no correlation between the variables.
An upward-sloping line indicates a positive correlation, while a downward-sloping line suggests a negative correlation.
Correlation coefficients can be interpreted as weak, moderate, or strong based on their values relative to 0, 0.6, and 0.8.
The video provides an example of a positive correlation between car age and its trade-in value.
A negative correlation example is given with car engine size and fuel consumption per liter.
Heat maps are introduced as a visual tool to represent correlation coefficients between variables.
Diagonal values in a heat map always show a correlation of 1, as they represent the relationship of a variable with itself.
The video demonstrates how to interpret heat maps to understand the strength of correlations.
Correlation is essential for building predictive models in machine learning and artificial intelligence, as it helps in assigning weights and metrics.
The video encourages viewers to subscribe for detailed, step-by-step content and source code availability.
The presenter offers to answer questions and suggestions in the comments section for further clarification.
Transcripts
Você já ouviu falar ou você sabe o que é
correlação ou seja correlação entre
variáveis a correlação ela é muito
importante dentro da ciência de dados
Então nesse vídeo eu quero te explicar
tudo bem detalhes O que é correlação
para que ela serve e como que a gente
interpreta isso identifica isso através
de gráficos Então bora lá aprender vem
comigo
Olá se você ainda não me conhece meu
nome é Jefferson eu sou o criador do
canal e aqui comigo Você é muito
bem-vindo Bora colocar a mão na massa
aqui entender o que que é correlação
vamos lá primeiramente eu não vou ler
aqui eu vou te explicar o seguinte com
relação nada mais é do que uma relação
que uma variável tem com outra ou seja o
valor de uma variável aumenta o outro
valor diminui ou vice-versa tem alguma
causa algum Impacto uma variável com a
outra então a correlação nada mais é do
que é mensurar através do seu
coeficiente de correlação Qual que é a
relação de uma variável com outra e
quando a gente tá ali interpretando E
analisando as variáveis se tem
correlação uma com a outra a gente
utiliza para medir isso o coeficiente de
relação que é um número que vai de um a
menos um nunca vai ser menor que menos
um e nunca vai ser maior que um e a
gente diz o seguinte quando o valor É
próximo de um ou se aproxima de um é um
se diz que existe uma correlação forte
positiva e quando a correlação o valor
se aproxima de -1 significa e a gente
diz que existe uma correlação forte
negativa através desse imagem aqui a
gente consegue ilustrar melhor Olha lá
aqui no zero é quando não existe
correlação ou a correlação é nula eu vou
te mostrar mais abaixo os gráficos e te
explicar como interpretá-los mas aqui é
o seguinte mas quando a gente tem aqui
por exemplo a correlação mais próxima de
-1 a gente tem uma correlação negativa
forte ou uma correlação forte negativa
né cada pessoa fala de um jeito mas o
conceito em si é esse tá e quando a
gente tem ali o valor próximo de um a
gente tem uma correlação positiva forte
é uma correlação forte positiva quando é
exatamente um ou menos um se diz que é
uma correlação negativa perfeita e
quando é um exatamente um coeficiente de
correlação se diz que é uma correlação
positiva perfeita Então olha lá agora
para a gente montar os nossos gráficos
aqui a gente vai importar os pacotes só
para a gente poder gerar os gráficos ali
a gente vai importar esse arquivo aqui
tá que vai ser o nosso Data Frame vamos
visualizar então aqui é um Data Frame de
exemplos com números de exemplos Não se
apegue a o valor desse carro é esse
mesmo há um ano desse carro custa isso
mesmo não aqui os valores são apenas
para a gente demonstrar ali as
correlações Ok Então olha lá aqui se a
gente gerar aqui um gráfico Descartes
plot quando a gente gera um gráfico de
caterpórter entre duas variáveis aqui a
gente tá comparando aqui ó no eixo X
nosso eixo X é o horizontal e o nosso Y
é o eixo vertical então quando a gente
gera um Skater plot a gente tá fazendo o
seguinte a gente tá querendo ver a
correlação da variável cilindradas
uma variável ano pode observar que aqui
olha a linha como ela tá aqui ó ou seja
isso não tem correlação a gente diz que
é uma correlação nula não existe aqui
relação nenhuma entre a variável ano e a
variável cilindradas uma não tem relação
nenhuma com a outra tá então aqui a
gente tem uma correlação neutra uma
correlação nulo ou seja não existe com
relação agora vamos ver um outro exemplo
aqui agora a gente vai querer avaliar a
variável ano em relação ao valor de
tabela Olha lá se a gente gerar aquilo
um gráfico novamente Opa aqui já tem uma
correlação e como que a gente interpreta
esse gráfico né aqui olha só aqui a
gente tem o ano e o valor de tabela
então a medida que o ano aqui vai
aumentando os valores aqui do veículo no
caso o valor da tabela ele também
aumenta ou seja aqui ó por exemplo nos
pontinhos aqui são os dados tá onde a
gente tem os nossos dados então em 2015
por exemplo se tem um carro ali no que o
ano dele é 2015 o valor de tabela dele
tá em torno de 25 mil se aumentou o ano
Ou seja que o carro é mais novo então
consequentemente o valor dele é mais
caro 2017 2018 2019 2020 e assim por
diante ou seja a cada ano que aumenta ou
seja conforme o carro vai ser no mais
novo significa que o valor do preço dele
tá aumentando tá vendo Então aqui a
gente tem uma correlação e é uma
correlação positiva a gente não sabe
ainda se é forte ou se não é porque a
gente pode ter uma correlação média tá
uma correlação forte é quando tá acima
de 0.6 aí já é considerado uma
correlação forte uma correlação acima de
0.8 é considerado muito forte e quando a
correlação é um é considerado perfeita
então ali ó acima de meio né 0.5 0.6
com relação já forte que nos modelos de
machine learning já tem muita relevância
Então olha lá aqui a gente já conseguiu
ver que a medida que o ano aumenta ou
seja o carro é mais novo o valor aumenta
então aqui a gente Já identificou que
existe uma correlação positiva e antes
da gente prosseguir agora que avaliar os
outros gráficos de correlação eu quero
dizer caso você ainda não seja inscrito
se escreve aqui no canal Porque toda
segunda quarta e sexta eu posso vídeos
novos sempre com conteúdo bem detalhado
tudo passo a passo na prática e ainda
disponibiliza os códigos fonte para
vocês então se inscreve aqui porque eu
creio que isso vai te ajudar bastante e
vamos voltar aqui agora e continuar
analisando nossas correlações agora
vamos ver se outro exemplo aqui que vai
gerar uma correlação negativa olha só
aqui nesse caso a gente tem uma
correlação negativa porque a gente tá
comparando ali a cilindradas com o
consumo por litro do carro ou seja
quantos quilômetros faz por litro agora
aqui é o contrário Então como que eu sei
primeiramente é pela linha tá vendo aqui
a linha ela está ao contrário dessa
linha aqui então aqui é correlação é
positiva A linha está subindo aqui como
a correlação é negativa A linha está
descendo E aí o que significa né A
medida que o meu carro aumenta a
potência o consumo dele ou seja fica
pior diminui Então olha só se eu tiver
aqui um carro de 1000 cilindradas que tá
aqui bem abaixo tá vendo no eixo Y Eu
tenho um carro 1.0 quantos quilômetros
por litro faz esse carro 12 agora por
exemplo eu aumentei a potência do meu
carro para 1.6 potência do carro 1.6
quanto que ele gasta 10 tá vendo já
diminuiu Eu aumentei a potência para 2.0
então quanto com carro 2.0 faz por litro
6 e um carro 2.4 Ah tá fazendo 4 Km por
litro então a medida que aumentando aqui
a potência eu tô diminuindo meu consumo
aqui tá vendo aqui são os pontos de
dados né Onde tá o nosso nosso valor ali
do Data Frame então a medida que eu
aumento aqui ó essa potência esse eixo
aqui que é o eixo Y A minha variável X
em vez de aumentar ela tá diminuindo
certo consumo aqui ó ele tá consumindo
mais então tem uma correlação negativa e
agora como que eu sei se a correlação é
forte negativa forte positiva aqui eu já
deixei marcado Tá vendo porque eu vou
disponibilizar aqui esse aqui para você
fazer no download tanto o arquivo aqui
como conjunto de dados para vocês
poderem fazer aí na máquina de vocês tá
mas para a gente avaliar que se ela é
forte se ela é fraca como que a gente
faz aqui se a gente pegar o nosso Data
Frame e colocar aqui ó esse método cor
co-r Abrir fechar parênteses a gente tem
aqui os coeficientes de relação ele vai
nos mostrar que o coeficiente de relação
de cada variável Agora imagina se você
tiver milhares milhões de dados aqui a
gente tem 1520 só para demonstrar mas
você vai ficar olhando aqui tudo e
fazendo conta para calcular ali ver se o
coeficiente é forte ou não não tem
necessidade disso porque através de
gráficos a gente verifica isso um
gráfico muito legal da gente Observar
isso que a gente bate o olho já
interpreta isso é o gráfico de Hit map
Olha lá eu vou gerar aqui para gerar Ele
é bem simples tá aqui ó eu só tô
determinando o tamanho aqui que vai ser
o gráfico na tela e aqui ó é que eu tô
gerando o gráfico com Ciborne a gente
gera que o hit map né E vai passar os
dados ele vai gerar um gráfico para nós
eu vou mostrar aqui para vocês como aqui
o intuito é só demonstrar e falar sobre
a correlação e não sobre como gerar
gráfico Como deixar os gráficos melhores
mais visualmente ali atrativos eu já fiz
um outro vídeo eu vou deixar o link aqui
na descrição que é um vídeo onde eu
mostro como gerar mais de 40 tipos de
gráfico diferente é bem legal vale a
pena dar uma olhada e olha lá aqui a
gente tirando agora esse Hit map Olha o
que que a gente tem então aquele gera o
gráfico de Hit map para nós e como que a
gente interpreta isso né pode observar
que tanto no eixo Y como no eixo X nós
temos as mesmas variáveis certo ó são
exatamente as mesmas só que ele coloca
aqui os coeficientes de correlação e
aqui ó o gráfico ele nos mostra um
termômetro Ou seja a cor mais clarinha
aqui a correlação está em um tá aqui ó
que não é menos um aqui ó esse pontinho
Aqui é do termômetro tá então aqui é um
e Aqui ó pode observar que aqui a gente
tem ó no caso aqui o -1 - 75 - 50 - 25 e
aí como que a gente interpreta isso Bom
primeiramente é que sempre na diagonal
você vai ter um porque no caso aqui ó é
com relação da variável ano com ela
mesmo tá ano com um ano sempre vai ser
um aqui a mesma coisa cilindradas com
cilindradas vai ser um e assim por
diante então sempre a diagonal vai ser
um agora por exemplo eu quero ver a
variável ano a correlação dela com a
variável cilindradas Então qual que é a
correlação dela com a variável
cilindradas é aqui ó
0.005 menos
0.005 pode ver que ele tá rosa ou seja
ele tá meio que muito próximo de zero
que é 0.005 tá então se a gente pegar lá
uma correlação que a gente viu aqui no
nosso escape
cilindradas com consumo por litro se a
gente olhar aqui ó se ligadas aqui e
consumo por litro então a gente vem aqui
ó por litro
cilindrada cilindrada consumo por litro
Olha onde bate aqui ó
0.96 ela tá próximo da onde a de uma
correlação muito forte né não é isso que
o gráfico aqui ó nos mostrou aí a gente
olhando aqui ó esse valor do coeficiente
de correlação a gente sabe que ela é
muito forte né ela é forte vamos pegar
um outro exemplo que a gente viu de
correlação positiva Olha lá valor de
tabela com um ano Então vamos olhar lá
interpretar isso no nosso Hit map de
correlação Então olha lá o ano com o
valor tabela certo ó
0.98 aqui ó variável ano com valor
tabela tá vendo com valor tabela 0.98
Aonde tá aqui ó próximo de um então é
uma correlação forte positiva e as
outras variáveis a gente interpreta da
mesma forma a essa variável aqui ó olha
lá tá vendo eu tenho
0.45 de ela já tá quase ali sendo forte
né mas vamos pegar uma que tem um
pouquinho mais deixa eu ver aqui ó uma
correlação essa aqui ó 0.8 ela já tá bem
forte tá vendo o próximo de um se a
gente pegar aqui ó cilindradas né com
peso ali do veículo ela dá 0.85 vamos
gerar um escape aqui para a gente ver eu
vou copiar aqui ó vou colocar aqui
embaixo só para a gente gerar então aqui
ó é cilindradas cilindradas com nome da
variável é peso kg Olha lá vamos gerar
aqui ó olha lá tá vendo mostrou aqui
para nós uma correlação positiva
exatamente o que a gente tem aqui ó peso
com a cilindrada da 0.85 E ela tá bem
próximo de um Então ela é forte Então
ela é uma correlação aqui positiva forte
viu que legal e viu como é fácil
interpretar isso eu quis trazer para
vocês alguns muito simples mas tudo bem
detalhado passo a passo porque
correlação é algo muito importante
porque porque quando a gente tá montando
modelos preditivos modelos de machine
learning modelos de Inteligência
Artificial quando os algoritmos ali eles
estão trabalhando para criar a sua
função matemática ali do modelo
preditivo Ele sempre vai olhar as
variáveis numéricas as variáveis que tem
correlação entre si Ou seja que se
relacionam entre si e com base nisso ele
vai atribuindo pesos e métricas para
isso por isso que ela é tão importante
e a gente fazendo uma análise
exploratória sabendo identificar isso
isso nos ajuda muito se você ficou com
alguma dúvida eu tiver alguma sugestão
deixa para mim aqui nos comentários que
eu te respondo mais rápido possível
Muito obrigado e até o próximo vídeo
5.0 / 5 (0 votes)