<jupyter_start><jupyter_text>Decision Tree<jupyter_code>from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
from sklearn.tree import export_graphviz
import graphviz

SEED = 5
np.random.seed(SEED)
raw_treino_x, raw_teste_x, raw_treino_y, raw_teste_y = train_test_split(x, y, test_size = 0.25, stratify = y)
print("Treinaremos com %d elementos e testaremos com %d elementos" % (len(treino_x), len(teste_x)))


modelo = DecisionTreeClassifier(max_depth=3)
modelo.fit(raw_treino_x, raw_treino_y)
previsoes = modelo.predict(raw_teste_x)
dot_data = export_graphviz(modelo, out_file=None,
                           filled = True, rounded = True,
                           feature_names = x.columns,
                          class_names = ["não", "sim"])
grafico = graphviz.Source(dot_data)
grafico

acuracia = accuracy_score(raw_teste_y, previsoes) * 100
print("A acurácia foi %.2f%%" % acuracia)
grafico<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09056956115779645, 'fraction_numerical': 0.008403361344537815, 'mean_word_length': 4.612565445026178, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '249568', 'license': 'MIT', 'n_tokens_mistral': 391, 'n_tokens_neox': 380, 'n_words': 78, 'path': 'Machine Learning - 4rd Project.ipynb.ipynb', 'repo_name': 'RenanLacana/Machine-Learning-1', 'size': '1071'}