Skip to content

Commit

Permalink
Re-implemented the code to do correlation matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbette committed Jun 19, 2024
1 parent a995480 commit 0839ea6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 20 additions & 0 deletions npf/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,26 @@ def printline(n):
print(" %s : %.02f " % (vs, tot / n))
print("")

print('')

ys = np.ndarray(shape = (len(X), len(dataset)))

for i,d in enumerate(dataset):
ys[:,i] = d[2]
import pandas as pd
df = pd.DataFrame(np.concatenate((X,ys),axis=1),columns=list(vars_values.keys()) + [d[0] if d[0] else "y" for d in dataset])
print("Correlation matrix:")
corr = df.corr()
corr.style.background_gradient(cmap='viridis')
print(corr)
corr
import seaborn as sn
import matplotlib.pyplot as plt
sn.heatmap(corr, annot=True)
f = npf.build_filename(test, build, filename if not filename is True else None, {}, 'pdf', result_type, show_serie=False, suffix="correlation")
plt.savefig(f)
print(f"Graph of correlation matrix saved to {f}")

@classmethod
def buildDataset(cls, all_results: Dataset, test: Test) -> List[tuple]:
#map of every <variable name, format>
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
'importlib_metadata',
'npf-web-extension >= 0.6.4',
'jinja2',
'spellwise'
]
'spellwise',
'seaborn'
]

setuptools.setup(
name="npf",
Expand Down

0 comments on commit 0839ea6

Please sign in to comment.