ComeçarComece de graça

Examine correlations of the new features

Now that we have our volume and datetime features, we want to check the correlations between our new features (stored in the new_features list) and the target (5d_close_future_pct) to see how strongly they are related. Recall pandas has the built-in .corr() method for DataFrames, and seaborn has a nice heatmap() function to show the correlations.

Este exercício faz parte do curso

Machine Learning for Finance in Python

Ver curso

Instruções do exercício

  • Extend our new_features variable to contain the weekdays' column names, such as weekday_1, by concatenating the weekday number with the 'weekday_' string.
  • Use Seaborn's heatmap to plot the correlations of new_features and the target, 5d_close_future_pct.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Add the weekday labels to the new_features list
new_features.extend([____ + ____ for i in range(1, 5)])

# Plot the correlations between the new features and the targets
sns.____(lng_df[____ + ['5d_close_future_pct']].corr(), annot=True)
plt.yticks(rotation=0)  # ensure y-axis ticklabels are horizontal
plt.xticks(rotation=90)  # ensure x-axis ticklabels are vertical
plt.tight_layout()
plt.show()
Editar e executar o código