<jupyter_start><jupyter_text><jupyter_code>#Import the Decision Tree Classifier
import numpy as np
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
#Import the Dataset (Zoo)

dataset = pd.read_csv('zoo.csv',
                      names = ['animal_name', 'hair', 'feathers', 'eggs', 'milk', 'airbone', 'aquatic', 'predator','toothed', 'backbone', 'breathes', 'venomous', 'fine', 'legs', 'tail', 'domestic', 'catsize', 'class',])



#Drop Animal Names

dataset = dataset.drop('animal_name', axis = 1)

print(dataset)
"""
Split the data into a training and a testing set
"""

train_features = dataset.iloc[:80,:-1]
test_features = dataset.iloc[80:,:-1]
train_targets = dataset.iloc[:80,-1]
test_targets = dataset.iloc[80:,-1]
"""
Train the model
"""

tree = DecisionTreeClassifier(criterion = 'entropy').fit(train_features,train_targets)
"""
Predict the classes of new, unseen data
"""
prediction = tree.predict(test_features)
"""
Check the accuracy
"""

print("The prediction accuracy is: ",tree.score(test_features,test_targets)*100,"%")<jupyter_output>The prediction accuracy is:  80.95238095238095 %
{'fraction_non_alphanumeric': 0.1572832886505809, 'fraction_numerical': 0.028596961572832886, 'mean_word_length': 5.91358024691358, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '650728', 'license': 'CC0-1.0', 'n_tokens_mistral': 406, 'n_tokens_neox': 374, 'n_words': 94, 'path': 'Decision_Tree_Using_sklearn.ipynb', 'repo_name': 'djswoosh/Uni-Bits', 'size': '1119'}