Spaces:
Sleeping
Sleeping
File size: 846 Bytes
d06d82c |
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 |
import joblib
import pandas as pd
def load_artifacts():
"""Load the trained pipeline and target encoder."""
pipeline = joblib.load("models/network_logs_pipeline.joblib")
target_encoder = joblib.load("models/target_encoder.joblib")
return pipeline, target_encoder
def predict_intrusion(pipeline, target_encoder, features: dict):
"""
Predict Scan_Type from input features.
Args:
pipeline: sklearn pipeline with preprocessing + model
target_encoder: LabelEncoder for Scan_Type
features: dict of input features
Returns:
str: Predicted Scan_Type
"""
input_df = pd.DataFrame([features]) # single row DataFrame
pred_label = pipeline.predict(input_df)[0]
scan_type = target_encoder.inverse_transform([pred_label])[0]
return scan_type
|