Skip to main content

GATree

GATree

PyPI version PyPI - Python Version PyPI - Downloads Downloads GATree Documentation status

Repository size License GitHub commit activity Percentage of issues still open Average time to resolve an issue GitHub contributors

DOI JOSS

📋 About • 📦 Installation • 🚀 Usage • 🧬 Genetic Operators • 🫂 Community Guidelines • 📜 License

📋 About

GATree is a Python library designed for implementing evolutionary decision trees using a standard genetic algorithm approach. The library provides functionalities for selection, mutation, and crossover operations within the decision tree structure, allowing users to evolve and optimise decision trees for various classification and clustering tasks. 🌲🧬

The library's core objective is to empower users in creating and fine-tuning decision trees through an evolutionary process, opening avenues for innovative approaches to classification and clustering problems. GATree enables the dynamic growth and adaptation of decision trees, offering a flexible and powerful tool for machine learning enthusiasts and practitioners. 🚀🌿

GATree is currently limited to classification and clustering tasks, with support for regression tasks planned for future releases. 💡

📦 Installation

pip

To install GATree using pip, run the following command:

pip install gatree

🚀 Usage

The following example demonstrates how to perform classification of the iris dataset using GATree. More examples can be found in the examples directory.

import pandas as pd
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from gatree.methods.gatreeclassifier import GATreeClassifier

# Load the iris dataset
iris = load_iris()
X = pd.DataFrame(iris.data, columns=iris.feature_names)
y = pd.Series(iris.target, name='target')

# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=¸10)

# Create and fit the GATree classifier
gatree = GATreeClassifier(n_jobs=16, random_state=32)
gatree.fit(X=X_train, y=y_train, population_size=100, max_iter=100)

# Make predictions on the testing set
y_pred = gatree.predict(X_test)

# Evaluate the accuracy of the classifier
print(accuracy_score(y_test, y_pred))

🧬 Genetic Operators in GATree

The genetic algorithm for decision trees in GATree involves several key operators: selection, elitism, crossover, and mutation. Each of these operators plays a crucial role in the evolution and optimisation of the decision trees. Below is a detailed description of each operator within the context of the GATree class.

Selection

Selection is the process of choosing parent trees from the current population to produce offspring for the next generation. By default, GATree class uses tournament selection, a method where a subset of the population is randomly chosen, and the best individual from this subset is selected.

Elitism

Elitism ensures that the best-performing individuals (trees) from the current generation are carried over to the next generation without any modification. This guarantees that the quality of the population does not decrease from one generation to the next.

Crossover

Crossover is a genetic operator used to combine the genetic information of two parent trees to generate new offspring. This enables exploration, which helps in creating diversity in the population and combining good traits from both parents.

Mutation

Mutation introduces random changes to a tree to maintain genetic diversity and explore new solutions. This helps in avoiding local optima by introducing new genetic structures.

🫂 Community Guidelines

Contributing

To contribure to the software, please read the contributing guidelines.

Reporting Issues

If you encounter any issues with the library, please report them using the issue tracker. Include a detailed description of the problem, including the steps to reproduce the problem, the stack trace, and details about your operating system and software version.

Seeking Support

If you need support, please first refer to the documentation. If you still require assistance, please open an issue on the issue tracker with the question tag. For private inquiries, you can contact us via e-mail at tadej.lahovnik1@um.si or saso.karakatic@um.si.

📜 License

This package is distributed under the MIT License. This license can be found online at http://www.opensource.org/licenses/MIT.

Disclaimer

This framework is provided as-is, and there are no guarantees that it fits your purposes or that it is bug-free. Use it at your own risk!

Metadata

Release files for gatree 0.2.0

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

Source distribution (sdist)

Source distribution for gatree 0.2.0
File Size Uploaded Provenance Actions
gatree-0.2.0.tar.gz 12.4 kB Without provenance Details for gatree-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 29.9 kB

Release files / gatree-0.2.0.tar.gz

Download URL gatree-0.2.0.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b50536c4dc6a03edcc3a93c8a1222628aabca14fa52bdd3101b786d1c366a216
BLAKE2b-256 checksum
How to use checksums
23d080065f91a0666c0363b38ddf917d4971e7ba427774cefa3d6d808372ed3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.2 Windows/10

Release files / gatree-0.2.0-py3-none-any.whl

Download URL gatree-0.2.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a91ace64d437dd4cf64fd17219b082722ce20b254c2a8effd38d2e62ddfc751
BLAKE2b-256 checksum
How to use checksums
91a7ab4c2870f15d57ce908f797df4cfbc4e9fb8c7db41e137e6c412eb73739e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.2 Windows/10

Security for gatree 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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