Skip to main content
PyPI - Package version Downloads Profile views codecov.io Codacy Badge Code style: black Documentation Status docs/logos/logo1.png

thefittest is an open-source library designed for the efficient application of classical evolutionary algorithms and their effective modifications in optimization and machine learning. Our project aims to provide performance, accessibility, and ease of use, opening up the world of advanced evolutionary methods to you.

Installation

Basic installation (for evolutionary algorithms and symbolic regression):

pip install thefittest

This installation includes all evolutionary optimizers (GA, DE, SHADE, etc.) and symbolic regression with GP.

Neural networks on CPU or GPU:

python -m pip install "thefittest[torch]"

Neural estimators default to device="cpu". For CUDA, install the appropriate PyTorch build using https://pytorch.org/get-started/locally/ and select device="cuda". CUDA is optional.

Usage Example

The following example demonstrates how to use thefittest library with the SHADE optimizer to minimize a custom objective function. This quick start example showcases the main components needed to set up and run an optimization.

from thefittest.optimizers import SHADE

# Define the objective function to minimize
def custom_problem(x):
    return (5 - x[:, 0])**2 + (12 - x[:, 1])**2

# Initialize the SHADE optimizer with custom parameters
optimizer = SHADE(
    fitness_function=custom_problem,
    iters=25,
    pop_size=10,
    left_border=-100,
    right_border=100,
    num_variables=2,
    show_progress_each=10,
    minimization=True,
)

# Run the optimization
optimizer.fit()

# Retrieve and print the best solution found
fittest = optimizer.get_fittest()
print('The fittest individ:', fittest['phenotype'])
print('with fitness', fittest['fitness'])

Machine Learning Example

This example demonstrates how to train a machine learning model on the Iris dataset using thefittest library’s MLPEAClassifier with the SHAGA evolutionary optimizer.

from thefittest.optimizers import SHAGA
from thefittest.benchmarks import IrisDataset
from thefittest.classifiers import MLPEAClassifier

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import minmax_scale
from sklearn.metrics import confusion_matrix, f1_score

# Load the Iris dataset
data = IrisDataset()
X = data.get_X()
y = data.get_y()

# Scale features to the [0, 1] range
X_scaled = minmax_scale(X)

# Split the data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.1)

# Initialize the MLPEAClassifier with SHAGA as the optimizer
model = MLPEAClassifier(
    n_iter=500,
    pop_size=500,
    hidden_layers=[5, 5],
    weights_optimizer=SHAGA,
    weights_optimizer_args={"show_progress_each": 10}
)

# Train the model
model.fit(X_train, y_train)

# Make predictions on the test set
predict = model.predict(X_test)

# Evaluate the model
print("confusion_matrix: \n", confusion_matrix(y_test, predict))
print("f1_score: \n", f1_score(y_test, predict, average="macro"))

Documentation

For detailed installation instructions, usage examples, API reference, and additional information, see the official documentation.

Awards and Presentations

  • 1st place, Samsung Innovation Campus (IT Academy), Artificial Intelligence track, October 2024. Read more;

  • Best PhD Student Paper at the 12th International Workshop on Mathematical Models and their Applications (IWMMA’2023) for the paper “Thefittest: Evolutionary Machine Learning in Python” by Pavel Sherstnev. Watch presentation;

  • Tutorial Presenter at the 13th International Workshop on Mathematical Models and their Applications (IWMMA’2024) with the tutorial titled “Thefittest Library: Evolutionary Algorithms and Automation of Machine Learning Models Design in Python”. Watch tutorial;

  • 2nd place, Youth IT Project Competition “Soft-Parade 2025”. More details

  • 2nd place, GitVerse, Cloud.ru and Habr Open Source Grant Program “Code Without Borders” 2025. More details

  • International University Award “Gravitation” 2025 in the category “Algorithms and Software Solutions in AI and Big Data”, awarded by the Presidential Academy, Tomsk State University, and the Association “University Consortium of Big Data Researchers”. More details

Metadata

Release files for thefittest 0.3.1

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

Source distribution (sdist)

Source distribution for thefittest 0.3.1
File Size Uploaded Provenance Actions
thefittest-0.3.1.tar.gz 2.5 MB Without provenance Details for thefittest-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 5.1 MB

Release files / thefittest-0.3.1.tar.gz

Download URL thefittest-0.3.1.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
a0a7e56cf8c610233ed9229ce4d9c88406eaa82dd3f3180a5c5f4c2a7cb2de57
BLAKE2b-256 checksum
How to use checksums
2fbaaf58bae201f8cfc2ac104d5b581e14cb8d98f81d8cef92c05f53b97374ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.1

Release files / thefittest-0.3.1-py3-none-any.whl

Download URL thefittest-0.3.1-py3-none-any.whl
Size 2.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b1ebc0b54a8028176aedd84afa2cb84c788101b2bdff3dae97728a342c814462
BLAKE2b-256 checksum
How to use checksums
59e9de6a1b05c042c7e7cee3e6ad09ff8286418fdeea196f31cc4f7b71f481e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.1

Security for thefittest 0.3.1

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