[[原因メトリクスとSLIメトリクスの相関が低いケース]]を解決するには?
## 1. 時系列を変化点位置、あるいは異常位置の時系列に変換し、類似度を計算する
- [[2020__IWQoS__Localizing Failure Root Causes in a Microservice through Causality Inference|MicroCause]]のように[[SPOT]]を使う
- [[ハミング距離]]などを使う?
## 2. [[相互相関]]を使う?
- [[原因メトリクスとSLIメトリクスの相関が低いケース]]に対して、相互相関の最大値は0.83になった。
```python
def xcorr(a: np.ndarray, b: np.ndarray) -> np.ndarray:
a_dev = a - a.mean()
b_dev = b - b.mean()
xc_ab = np.correlate(a_dev, b_dev, mode="full")
# normalize
xc_ab /= np.linalg.norm(a_dev, ord=2) * np.linalg.norm(b_dev, ord=2)
return xc_ab
out = xcorr(record.data_df["s-front-end_throughput"].to_numpy(), record.data_df["c-user_memory_usage_bytes"].to_numpy())
print(np.argmax(np.abs(out)), np.max(np.abs(out)))
plt.plot(out)
```
![[Pasted image 20230413121950.png|400]]
ランダムウォーク前のノードの重み付けについて、相互相関に変更して実験したところ、ピアソン相関よりもわずかにmemory-hogのケースでスコアがよくなった。 AC@5 0.19 -> 0.30
- before: https://new-ui.neptune.ai/html-renderer/?experimentIdentifier=98daf85a-ec77-46a3-bc17-513cb4041f1b&attribute=eval%2Fscore-df-by-cause-type
- after: https://new-ui.neptune.ai/html-renderer/?experimentIdentifier=98eb98a7-5401-4f03-ad02-2228b4d68134&attribute=eval%2Fscore-df-by-cause-type