Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. %matplotlib inline
  2. from sklearn.tree import DecisionTreeClassifier
  3. from sklearn.datasets import load_breast_cancer
  4. import numpy as np
  5. import matplotlib.pyplot as plt
  6. import pandas as pd
  7. import mglearn
  8. from sklearn.tree import DecisionTreeClassifier
  9. from sklearn.model_selection import train_test_split
  10.  
  11. cancer = load_breast_cancer()
  12.  
  13. X_train, X_test, y_train, y_test = train_test_split(
  14.  cancer.data, cancer.target, stratify=cancer.target, random_state=42)
  15.  
  16. tree = DecisionTreeClassifier(random_state=0)
  17. tree.fit(X_train, y_train)
  18.  
  19. print("Accuracy on training set: {:.3f}".format(tree.score(X_train, y_train)))
  20. print("Accuracy on test set: {:.3f}".format(tree.score(X_test, y_test)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement