Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Correlation Matrix | Correlation
Explore the Linear Regression Using Python

Scorri per mostrare il menu

book
Correlation Matrix

Let’s go back to our dataset. To explore the relationships between all the columns, we can use a correlation matrix. It finds pairwise correlation coefficients of all columns(that's why the matrix is symmetric). Use the following method to build it and show correlation coefficients between all variables: dataframe.corr().

Use this code to see the matrix for our wine dataset:

12
matrix= data.corr().round(2) print(matrix)
copy

If we want to visualize this matrix just call function sns.heatmap and import library:

12
import seaborn as sns sns.heatmap(matrix, annot=True)
copy

If you want to improve your knowledge in Seaborn Visualization, click here!

We can see that alcohol is most positively correlated with the proline (0.64), which means that the amount of alcohol increases as the proline. The hue is most negatively correlated with the color intensity (-0.52), which means that the greater the color intensity of the wine, the lower the hue.

Compito

Swipe to start coding

In the future, we will try to predict the characteristics of wine by the number of flavanoids in it. Flavanoids are plant pigments, and their most prominent role is to color our crops brightly.

  1. [Lines #3-4] Import the pandas, seaborn libraries.
  2. [Line #17] Write the code to define the correlation matrix rounding it to the second digit.
  3. [Lines #20-24] Find with which column flavanoids have the highest positive correlation and the negative correlation. Using the previous diagram we can obviously find that that's total_phenols (0.86) and nonflavanoid_phenols(-0.54) respectively. Assign numbers above to the variables positive_cor_value and negative_cor_value respectively (positive_cor_value = 0.86 and negative_cor_value = -0.54). Assign names and numbers to the corresponding variables.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 2
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?

Chieda ad AI

expand
ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

book
Correlation Matrix

Let’s go back to our dataset. To explore the relationships between all the columns, we can use a correlation matrix. It finds pairwise correlation coefficients of all columns(that's why the matrix is symmetric). Use the following method to build it and show correlation coefficients between all variables: dataframe.corr().

Use this code to see the matrix for our wine dataset:

12
matrix= data.corr().round(2) print(matrix)
copy

If we want to visualize this matrix just call function sns.heatmap and import library:

12
import seaborn as sns sns.heatmap(matrix, annot=True)
copy

If you want to improve your knowledge in Seaborn Visualization, click here!

We can see that alcohol is most positively correlated with the proline (0.64), which means that the amount of alcohol increases as the proline. The hue is most negatively correlated with the color intensity (-0.52), which means that the greater the color intensity of the wine, the lower the hue.

Compito

Swipe to start coding

In the future, we will try to predict the characteristics of wine by the number of flavanoids in it. Flavanoids are plant pigments, and their most prominent role is to color our crops brightly.

  1. [Lines #3-4] Import the pandas, seaborn libraries.
  2. [Line #17] Write the code to define the correlation matrix rounding it to the second digit.
  3. [Lines #20-24] Find with which column flavanoids have the highest positive correlation and the negative correlation. Using the previous diagram we can obviously find that that's total_phenols (0.86) and nonflavanoid_phenols(-0.54) respectively. Assign numbers above to the variables positive_cor_value and negative_cor_value respectively (positive_cor_value = 0.86 and negative_cor_value = -0.54). Assign names and numbers to the corresponding variables.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 2
Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt