Guest User

Untitled

a guest
Feb 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import pandas as pd
  3. from sklearn.model_selection import train_test_split
  4. from sklearn.svm import SVC
  5. from sklearn import metrics
  6. from sklearn.metrics import classification_report, confusion_matrix
  7.  
  8.  
  9.  
  10. fruits = pd.read_csv('fruitscsv.csv')
  11. print(fruits.head())
  12. print(fruits.shape)
  13.  
  14. X = fruits[['mass','width','height','color_score']]
  15. Y = fruits['fruit_label']
  16.  
  17. plt.scatter(X['height'], X['color_score'], c=Y, cmap=plt.cm.Paired) #first
  18. plt.show()
  19.  
  20. X_train,X_test,y_train,y_test=train_test_split(X,Y, test_size=0.2, random_state=30)
  21.  
  22. svclassifier = SVC(kernel='linear')
  23. svclassifier.fit(X_train, y_train)
  24.  
  25. y_pred = svclassifier.predict(X_test)
  26. print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
  27.  
  28. print(confusion_matrix(y_test,y_pred))
  29. print(classification_report(y_test,y_pred))
Add Comment
Please, Sign In to add comment