We propose a framework for the systematic and quantitative generalization of Bell's theorem using causal networks. We first consider the multi-objective optimization problem of matching observed data while minimizing the causal effect of nonlocal variables and prove an inequality for the optimal region that both strengthens and generalizes Bell's theorem. To solve the optimization problem (rather than simply bound it), we develop a novel genetic algorithm treating as individuals causal networks. By applying our algorithm to a photonic Bell experiment, we demonstrate the trade-off between the quantitative relaxation of one or more local causality assumptions and the ability of data to match quantum correlations.While it seems conceptually obvious that causality lies at the heart of physics, its exact nature has been the subject of constant debate. The fundamental implications of quantum theory shed new light on this debate. It is thought these implications may lead to new insights into the foundations of quantum theory, and possibly even quantum theories of gravity [1][2][3][4][5][6][7][8][9][10].These realizations have their roots in the EinsteinPodolski-Rosen thought experiment [11] and the fundamental theorems of Bell [12] and of Kochen and Specker [13]. A cornerstone of modern physics, Bell's theorem, rigorously excludes classical concepts of causality. Roughly speaking Bell's theorem states that the following concepts are mutually inconsistent: (1) reality; (2) locality; (3) measurement independence; and (4) quantum mechanics.In philosophical discussions, typically one rejects (1) or (2), which together are often referred to as local causality, though the other options have been considered as well. In studies with an operational bent, however, one often considers relaxations of (2) or (3) which is what we concern ourselves with here. These relaxations have been addressed from different perspectives, but only regarding specific causal influences in isolation [14][15][16][17][18][19][20][21][22][23], whereas here we wish to study all possible relaxations of the causal assumptions implied by (2) and (3) simultaneously.The framework of causal networks [24,25] is wildly successful within the field of machine learning and has led some physicists to utilize them to elucidate the tension between causality and Bell's theorem. Recently, Wood and Spekkens have shown that existing principles behind causal discovery algorithms (namely, the absence of fine tuning) still cannot be reconciled with entanglement induced quantum correlations even if one admits nonlocal models [9]. However, such results only hold for the exact distributions, and would not necessarily apply to exper- * These authors contributed equally to this work.imental data due to measurement noise, or a relaxation of the demand of reproducing exactly the quantum correlations. Clearly, the further away from the quantum correlations one is allowed to stray, the more likely a locally causal model can be found.Here we propose a framework for systematic and qua...