Display correlation values in AutoCorrelationsResult

This commit is contained in:
RunasSudo 2024-05-16 22:56:10 +10:00
parent 90cc780086
commit 7d080f7d20
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -314,4 +314,19 @@ class AutoCorrelationsResult:
"""
import seaborn as sns
sns.heatmap(self.correlations, vmin=-1, vmax=1, cmap='RdBu')
# Format values without leading 0
def fmt_value(v):
if v >= 0.995:
return '1.0'
if v <= -0.995:
return '-1.0'
if v < 0:
if v >= -0.005:
return '.00'
return '-' + format(-v, '.2f').lstrip('0')
return format(v, '.2f').lstrip('0')
correlation_values = self.correlations.applymap(fmt_value)
sns.heatmap(self.correlations, vmin=-1, vmax=1, cmap='RdBu', annot=correlation_values, fmt='', annot_kws={'fontsize': 'small'})