fix transform issue

1. change fit_transform to transform for test data, it will increase F1 score
2. Add output for confusion_matrix and classification_report to understand the classification result
This commit is contained in:
Jack Huang
2018-08-21 15:54:28 +08:00
committed by GitHub
parent 4956b84872
commit 19be35cd9d

View File

@ -18,7 +18,7 @@ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, rand
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.fit_transform(X_test)
X_test = sc.transform(X_test)
#Fitting SVM to the Training set
from sklearn.svm import SVC
@ -30,7 +30,10 @@ y_pred = classifier.predict(X_test)
#Making the Confusion Matrix
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
cm = confusion_matrix(y_test, y_pred)
print(cm)
print(classification_report(y_test, y_pred))
#Visualising the Training set results
from matplotlib.colors import ListedColormap