|
|
|
from sklearn.svm import SVC |
|
import joblib |
|
from sklearn.metrics import accuracy_score, classification_report |
|
|
|
X_train_tfidf = joblib.load('X_train_tfidf.pkl') |
|
X_test_tfidf = joblib.load('X_test_tfidf.pkl') |
|
y_train = joblib.load('y_train.pkl') |
|
y_test = joblib.load('y_test.pkl') |
|
|
|
svm_model = SVC(kernel='linear', random_state=42) |
|
svm_model.fit(X_train_tfidf, y_train) |
|
y_pred = svm_model.predict(X_test_tfidf) |
|
accuracy = accuracy_score(y_test, y_pred) |
|
print(f"Accuracy: {accuracy:.4f}") |
|
print(classification_report(y_test, y_pred)) |
|
|