<jupyter_start><jupyter_text><jupyter_code>import pandas as pd;
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn import metrics
dados = pd.read_csv('diabetes.csv')
dados.columns
features_columns = ['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness', 'Insulin',
       'BMI', 'DiabetesPedigreeFunction', 'Age']
x = dados[features_columns]
y = dados.Outcome
x.shape
x_train, x_test, y_train, y_test = train_test_split(x,y, test_size=0.3, random_state=4)
x_test.shape
clf = DecisionTreeClassifier(max_depth=4, splitter='best')
clf = clf.fit(x_train, y_train)
y_pred = clf.predict(x_test)
y_pred[0]
print(metrics.accuracy_score(y_test, y_pred))
print(metrics.confusion_matrix(y_test, y_pred))
from sklearn.externals.six import StringIO
from IPython.display import Image
from sklearn.tree import export_graphviz
import pydotplus
dot_data = StringIO()
export_graphviz(clf, out_file=dot_data,
 filled= True, rounded=True,
 special_characters= True,
feature_names = feature_cols,
class_names=[ '0','1'])
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.write_png( 'diabetes.png' )
Image(graph.create_png())<jupyter_output>/usr/local/lib/python3.7/dist-packages/sklearn/externals/six.py:31: FutureWarning: The module is deprecated in version 0.21 and will be removed in version 0.23 since we've dropped support for Python 2.7. Please rely on the official version of six (https://pypi.org/project/six/).
  "(https://pypi.org/project/six/).", FutureWarning)
{'fraction_non_alphanumeric': 0.11986970684039087, 'fraction_numerical': 0.012377850162866449, 'mean_word_length': 6.958549222797927, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '541140', 'license': 'MIT', 'n_tokens_mistral': 566, 'n_tokens_neox': 537, 'n_words': 119, 'path': 'Untitled3.ipynb', 'repo_name': 'Marinamontelo/WhatsApp-Business-API-Setup-Scripts', 'size': '1535'}