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.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 thefittest 0.3.0
File Size Uploaded Provenance Actions
thefittest-0.3.0.tar.gz 2.5 MB Without provenance Details for thefittest-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 5.1 MB

Release files / thefittest-0.3.0.tar.gz

Download URL thefittest-0.3.0.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
a26dec46c35ac93f6478067dce762fbec96bcfa14cfddffae29a180382eb08cb
BLAKE2b-256 checksum
How to use checksums
f68aecb912e0ef3ad4a816bb79c1c2f0f049da10e97f685da46a86ade11be815
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.0-py3-none-any.whl

Download URL thefittest-0.3.0-py3-none-any.whl
Size 2.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
71fd5871d6aa1ba36f82a64f0b9c449cd5d3fafb1ea446e16c9e636c2007bc2a
BLAKE2b-256 checksum
How to use checksums
1a2beb03429a30848983bbb6b5f3733eda74680b143aad24750b3ce9c1e3c77d
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.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