🔨 Refactors analyzing into one function

This commit is contained in:
Daniel Svitan
2024-12-15 12:00:04 +01:00
parent d03ef94d4f
commit bade4ec45c
3 changed files with 40 additions and 30 deletions

View File

@@ -1,5 +1,6 @@
import numpy as np
import scipy.stats as stats
from analyze import analyze
dataset = np.load("clean.npy")
print(f"dataset shape: {dataset.shape}, analyzing column 1 (sex)")
@@ -8,19 +9,12 @@ print("\t1 - male")
print("")
def analyze(name: str, col: np.ndarray):
def analyze_sex(name: str, col: np.ndarray):
sex_col = dataset[:, 1]
F, p = stats.f_oneway(col[sex_col == 0], col[sex_col == 1])
print(f"F-stats for {name}: {F}")
print(f"p-value for {name}: {p}")
if p > 0.05:
print("statistically insignificant\n")
return
print("statistically significant")
tukey_results = stats.tukey_hsd(col[sex_col == 0], col[sex_col == 1])
print(tukey_results)
analyze(name, [
col[sex_col == 0],
col[sex_col == 1]
])
analyze("gpa", dataset[:, 2])