Closed shntnu closed 2 weeks ago
Sometimes both, strong positive and strong negative correlations are meaningful, so we should allow for that.
One way to do this is to add a boolean absolute_value argument to pairwise_cosine
absolute_value
pairwise_cosine
https://github.com/cytomining/copairs/blob/c10c93e1371c2209975b2ef3603fb34fd597d107/src/copairs/compute.py#L65-L69
def pairwise_cosine(x_sample: np.ndarray, y_sample: np.ndarray, absolute_value: bool = False) -> np.ndarray: x_norm = x_sample / np.linalg.norm(x_sample, axis=1)[:, np.newaxis] y_norm = y_sample / np.linalg.norm(y_sample, axis=1)[:, np.newaxis] c_sim = np.sum(x_norm * y_norm, axis=1) if absolute_value: c_sim = np.abs(c_sim) return c_sim
Is that reasonable?
Sometimes both, strong positive and strong negative correlations are meaningful, so we should allow for that.
One way to do this is to add a boolean
absolute_value
argument topairwise_cosine
https://github.com/cytomining/copairs/blob/c10c93e1371c2209975b2ef3603fb34fd597d107/src/copairs/compute.py#L65-L69