Advertisement
EXTREMEXPLOIT

SoutiPlot

May 23rd, 2020
1,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #valores = final_dataset.values
  2. X = final_dataset.iloc[:,:-1]
  3. Y = final_dataset.iloc[:,-1]
  4. #Creamos un array con los modelos que emplearemos
  5. models = []
  6. models.append(('SVM', SVC(kernel='rbf')))
  7. models.append(('Naive_Bayes', GaussianNB()))
  8. models.append(('Decision_Trees', DecisionTreeClassifier()))
  9.  
  10. results = []
  11. names = []
  12. for name, model in models:
  13.     KF = KFold(n_splits=5)
  14.     cv_results = cross_val_score(model, X, Y, cv=KF.get_n_splits(), scoring='accuracy')
  15.     results.append(cv_results)
  16.     names.append(name)
  17.     msg = "%s: %f (%f)" % (name, cv_results.mean(), cv_results.std())
  18.     print(msg)
  19. # boxplot algorithm comparison
  20. fig = plt.figure()
  21. fig.suptitle("Algorithm accuracy comparison")
  22. ax = fig.add_subplot(111)
  23. plt.boxplot(results)
  24. ax.set_xticklabels(names)
  25. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement