Sep-03-2023, 11:58 AM
(Sep-03-2023, 02:17 AM)deanhystad Wrote: What do you want to average, acc?
def run_experiment(): from notears import utils # utils.set_random_seed(1) this line cannot be used to ensure different outcomes in each round of the loop n, d, s0, graph_type, sem_type = 1000, 20, 20, 'ER', 'gauss' B_true = utils.simulate_dag(d, s0, graph_type) W_true = utils.simulate_parameter(B_true) np.savetxt('W_true.csv', W_true, delimiter=',') X = utils.simulate_linear_sem(W_true, n, sem_type) np.savetxt('X.csv', X, delimiter=',') W_est = notears_linear(X, lambda1=0.1, loss_type='l2') assert utils.is_dag(W_est) np.savetxt('W_est.csv', W_est, delimiter=',') return utils.count_accuracy(B_true, W_est != 0) if __name__ == '__main__': acc = [run_experiment() for _ in range(num_experiments)] print("Average acc =", sum(acc) / len(acc))You should not use assert.
Yes, I want to get the average value of acc. The current acc gives me a list like this: {'fdr': 0.0, 'tpr': 0.95, 'fpr': 0.0, 'shd': 1, 'nnz': 19}