-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinference.py
More file actions
19 lines (16 loc) · 788 Bytes
/
Copy pathinference.py
File metadata and controls
19 lines (16 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.svm import LinearSVC
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics import classification_report
import joblib
loaded_model = joblib.load("svm.joblib")
loaded_vectorizer = joblib.load("vectorizer.joblib")
loaded_label_encoder = joblib.load("label_encoder.joblib")
# Step 8: Predict for a new input
new_input = ["User Eve uploaded a malicious script"] # You can replace this with any input
new_input_tfidf = loaded_vectorizer.transform(new_input)
prediction = loaded_model.predict(new_input_tfidf)
# Decode label
predicted_severity = loaded_label_encoder.inverse_transform(prediction)
print(f"Predicted severity: {predicted_severity[0]}")