# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Classification and Regression Trees
# Classification and Regression Trees (CART) are constructed from a dataset by making splits that best separate the data for the classes or predictions being made. The CART algorithm can be used for classification or regression.

from sklearn import datasets
from sklearn import metrics
from sklearn.tree import DecisionTreeClassifier

# # Iris flowers Dataset

dataset = datasets.load_iris()

# # Model

model = DecisionTreeClassifier()
model.fit(dataset.data, dataset.target)

# # Prediction/Classification

expected = dataset.target
predicted = model.predict(dataset.data)
print(metrics.classification_report(expected, predicted))
print(metrics.confusion_matrix(expected, predicted))

# ## References
# 1. https://machinelearningmastery.com/get-your-hands-dirty-with-scikit-learn-now/

StarcoderdataJupyterScriptsDedupFiltered