Skip to main content

DEEPTREE

A simple Decision Tree Classifier

Overview

This project is a custom implementation of a decision tree classifier inspired from scikit-learn-decision-tree-classifier. The classifier is built from scratch without any external dependencies.

Gini index is used by the classifier to construct the decision tree. Using the gini index for partitioning has allowed the classifier to handle both continuous and categorical features. This allows the classifier to be used in a wider range of applications and datasets.

In addition, the classifier also includes a basic tree printing functionality, which can be used to visualize the tree structure and gain a better understanding of how the classifier is making its decisions.

Features

  • No external dependencies
  • Handles both continuous and categorical features
  • Uses Gini index to measure impurity of partion
  • Includes basic tree printing functionality for tree visualization

Requirements

Python 3.x [Optional] Any text editor or IDE of your choice for editing the code.

Installation

deeptree can be installed using the following command:

pip install deeptree

or

pip3 install deeptree

Dependencies

deeptree is built using only in built python libraries.

Functionalities

The functions in deeptree package come as part of two classes Node and Classifier. The functions are:-

deeptree.Node.get_feature_midpoints(i=0)

This function finds the midpoints for any continuous feature corresponding to index 'i' in the dataset.

deeptree.Node.get_splitting_subsets(i=0)

This function finds the splitting subsets for any discrete feature corresponding to index 'i' in the dataset.

deeptree.Node.get_gini_value()

This function calculates the gini value of the deeptree node.

deeptree.Classifier.fit(dataset=[],label_index=-1)

This function trains the decision tree classifier on the given dataset.

deeptree.Classifier.predict(dataset=[]):

This function predicts the labels/classes of the given dataset.

deeptree.Classifier.print_tree(node, level=0)

This function prints the structure of the decision tree with the details at each node.

Example on how to use deeptree are provided in example.py. The example is based on the iris.data dataset downloaded from UCI achine learning repository.

License

MIT License

Acknowledgments

The source code for this project was created as part of one of the courseworks for MSc. Data Science program at Lancaster University. Thanks to Leandro Soriano Marcolino for his amazing classes and this coursework topic.

Release files for deeptree 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deeptree 0.0.2
File Size Uploaded
deeptree-0.0.2.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for deeptree 0.0.2
File Interpreter ABI Platform
deeptree-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / deeptree-0.0.2.tar.gz

Download URL deeptree-0.0.2.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dc87a0d1424d75f75db14aae56457177fb9cd94597b501d74a2de6b35189826f
BLAKE2b-256 checksum
How to use checksums
57ee199aae996e87d72e0fece3d7dfb25d98e114378d2d8d43d6bbba245ffff2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / deeptree-0.0.2-py3-none-any.whl

Download URL deeptree-0.0.2-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
deea7b2158a2491a73e85e029e8257b9a8aed41092792ad79109e19cad1228fd
BLAKE2b-256 checksum
How to use checksums
4fb721fbc805359d2c198c3991f650f465750c8e3a7aa14a942b412aa1e5735a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page