Correlation of Values (corr)¶
import math
from pyxla import load_data, corr
from pyxla.sampling import HilbertCurveSampler
sphere_sample = {
"name": "Sphere",
"X": HilbertCurveSampler(sample_size=100, dim=1, l_bound=-5, u_bound=5, seed=42),
"F": lambda x: x**2,
"V": [lambda x: x**2 - 2, lambda x: 8 * math.sin(20 * x)]
}
load_data(sphere_sample)
WARNING:root:The Hilbert curve with dimension 1 is just a number line. You are sampling around points on a number line.
corrs, plot = corr(sphere_sample)
/home/toni/Projects/pyxla-wg/src/pyxla/__init__.py:376: ConstantInputWarning: An input array is constant; the correlation coefficient is not defined.
cor, _ = spearmanr(x, y)
corrs
{'v0_f0 (feasible)': 'undefined',
'v0_f0 (infeasible)': '1.00',
'v1_f0 (feasible)': 'undefined',
'v1_f0 (infeasible)': '-0.28',
'v1_v0 (feasible)': 'undefined',
'v1_v0 (infeasible)': '-0.28'}