Spaces:
Sleeping
Sleeping
File size: 1,126 Bytes
1d6bb40 | 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import pandas as pd
import joblib
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
# Load dataset
df = pd.read_csv(
"C:\\Users\\chiya\\Documents\\meta-model-failure-prediction\\src\\data\\processed\\base_dataset.csv"
)
# Features
feature_columns = [
"vader_pred",
"vader_score",
"lr_pred",
"lr_confidence",
"bert_pred",
"bert_confidence",
"bert_entropy",
"vader_lr_disagreement",
"lr_bert_disagreement",
"vader_bert_disagreement",
"has_negative_intensifier"
]
X = df[feature_columns]
# Target
y = df["bert_failed"]
# Split
X_train, X_test, y_train, y_test = train_test_split(
X,
y,
test_size=0.2,
random_state=42
)
# Load trained model
meta_model = joblib.load(
"artifacts/meta_model.pkl"
)
# Predictions
y_pred = meta_model.predict(X_test)
# Confusion matrix
cm = confusion_matrix(y_test, y_pred)
# Plot
disp = ConfusionMatrixDisplay(
confusion_matrix=cm
)
disp.plot()
plt.title(
"Meta-Model Confusion Matrix"
)
plt.show() |