You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Fix #9: Also save le_event encoder so it can be reused for future inference
27
+
# Previously le_event was trained but never saved - now it is included in encoders.pkl
26
28
le_event=LabelEncoder()
27
-
df['event_encoded'] =le_event.fit_transform(df['event_type']) # In real scenario, we might not have 'event_type' for new anomalies, but for this demo we rely on patterns
28
-
29
-
# We will use Source IP as a feature? IP addresses are categorical but high cardinality.
30
-
# For a simple anomaly detection, let's look at Bytes and Protocol.
31
-
# A better approach for IPs is frequency encoding or just ignoring specific IPs and looking at behavior.
32
-
# Let's use Bytes and Protocol for simplicity for now.
33
-
34
-
features= ['bytes', 'protocol_encoded']
35
-
X=df[features]
36
-
37
-
print("Training Isolation Forest...")
38
-
# Contamination is the expected proportion of outliers
0 commit comments