ABED160105

Perkinson SVM Train accuracy test abed

Sep 28th, 2020 (edited)
1,870
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2.  
  3. data = pd.read_csv("data.csv")
  4.  
  5. # print(data)
  6.  
  7. from sklearn.model_selection import train_test_split
  8.  
  9. training_set, test_set = train_test_split(data, test_size=0.2, random_state=1)
  10.  
  11. X_train = training_set.iloc[:, 0:2].values
  12. Y_train = training_set.iloc[:, 2].values
  13. X_test = test_set.iloc[:, 0:2].values
  14. Y_test = test_set.iloc[:, 2].values
  15.  
  16. from sklearn.svm import SVC
  17.  
  18. classifier = SVC(kernel='rbf', random_state=1)
  19. classifier.fit(X_train, Y_train)
  20.  
  21. Y_pred = classifier.predict(X_test)
  22.  
  23. test_set["Predictions"] = Y_pred
  24.  
  25. from sklearn.metrics import confusion_matrix
  26.  
  27. cm = confusion_matrix(Y_test, Y_pred)
  28. accuracy = float(cm.diagonal().sum()) / len(Y_test)
  29. print("Accuracy : ", accuracy)
RAW Paste Data