Advertisement
Guest User

Untitled

a guest
Sep 24th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. from sklearn.datasets import load_iris
  2. from sklearn.model_selection import train_test_split
  3.  
  4. iris = load_iris()
  5. data = iris['data']
  6. labels = [0 if label == 0 else 1 for label in iris['target']]
  7.  
  8. training_features, testing_features, training_labels, testing_labels = train_test_split(data, labels)
  9.  
  10. model = RandomForest(n_trees=100)
  11. model.fit(training_features, training_labels)
  12.  
  13. accuracy = sum([label == prediction for label, prediction in zip(testing_labels, model.predict(testing_features))])/len(testing_labels)
  14.  
  15. print(f'Accuracy: {accuracy}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement