-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector_check.py
More file actions
28 lines (22 loc) · 993 Bytes
/
vector_check.py
File metadata and controls
28 lines (22 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import numpy as np
def mock_vector_test():
print("--- ?? NEXUS VECTOR INTEGRITY AUDIT (MANUAL) ---")
# Test cases for semantic similarity
doc1 = "Suspicious C2 beaconing detected on port 4444"
doc2 = "EDR Alert: Connection to malicious infrastructure"
doc3 = "Normal web traffic on port 80"
# In a real environment, we use TF-IDF. Here we validate the normalization logic.
print("[*] Verifying unit normalization requirement for cosine similarity...")
dummy_vec = np.array([0.1, 0.2, 0.3, 0.4])
norm = np.linalg.norm(dummy_vec)
normalized = dummy_vec / norm
final_norm = np.linalg.norm(normalized)
print(f" Initial Norm: {norm:.4f}")
print(f" Final Norm: {final_norm:.4f}")
if abs(final_norm - 1.0) < 1e-6:
print("[SUCCESS] Mathematical normalization is consistent.")
else:
print("[FAILURE] Precision error in normalization.")
if __name__ == "__main__":
mock_vector_test()