<jupyter_start><jupyter_text>Decision Tree<jupyter_code>from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier

iris = load_iris()
X = iris.data[:, 2:]
y = iris.target
tree_clf = DecisionTreeClassifier(max_depth=2)
tree_clf.fit(X, y)
import numpy as np
import os

PROJECT_ROOT_DIR = "."
CHAPTER_ID = "decision_trees"


def image_path(fig_id):
    return os.path.join(PROJECT_ROOT_DIR, fig_id)
from sklearn.tree import export_graphviz

export_graphviz(
    tree_clf,
    out_file=image_path("iris_tree.dot"),
    feature_names=iris.feature_names[2:],
    class_names=iris.target_names,
    rounded=True,
    filled=True
)<jupyter_output><empty_output><jupyter_text>Prediction<jupyter_code>tree_clf.predict_proba([[5, 1.5]])
tree_clf.predict([[5, 1.5]])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11808118081180811, 'fraction_numerical': 0.01107011070110701, 'mean_word_length': 6.752380952380952, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '525169', 'license': 'MIT', 'n_tokens_mistral': 334, 'n_tokens_neox': 324, 'n_words': 49, 'path': 'Decision Tree/.ipynb_checkpoints/DecisionTree-checkpoint.ipynb', 'repo_name': 'sckimynwa/Hands-On_ML', 'size': '813'}