A genetic algorithm library
Project description
Genetic Algorithm for Flexible Data Handling
A Python library that leverages genetic algorithms to generate optimized queries for handling data flexibly without dropping rows. This approach enables selective row exclusion per query, bypassing the need for imputation or deletion, and supports high-volume data processing through parallelism.
Features
- Generates custom queries to ignore specific rows based on query-specific criteria.
- Supports high-volume data processing with parallel computation.
- Dynamically calculates feature-specific min/max values for optimized filtering.
- Enables binary classification filtering and calculates the percentage of 1s.
Workflow
-
Load and Clean Data:
- Load data and apply minimal cleaning (e.g., drop
infvalues or other outliers that could disrupt quintile calculations).
- Load data and apply minimal cleaning (e.g., drop
-
Set Parameters:
- Define parameters that control the algorithm's behavior and query generation.
-
Dynamic Feature Computation:
- Compute min/max values and deltas dynamically for each feature to enhance query specificity.
-
Generate Feature-Specific Combinations:
- Produce min/max combinations for each feature based on unique criteria.
-
Filter Data:
- Filter CSVs using generated criteria, calculating the percentage of 1s for binary classification tasks (if applicable).
-
Genetic Algorithm Optimization:
- Carry over the fittest combinations to the next generation, introducing new entries at a defined rate for continuous improvement.
Installation
Install the package via pip:
pip install dynamic_genetic_algo
from dynamic_genetic_algo import GeneticAlgorithm, GeneticParams
# Define the genetic parameters
genetic_params = GeneticParams(
population_size=200,
elite_size=0.1,
mutation_rate=0.6,
generations=1000,
min_size_ratio=0.005, # Percent of dataset that must be retained to avoid anomalies
average_column="Example Target",
categorical_columns=id_dict, # Dictionary where key is column name and value is list of possible categories
super_elite=20 # Extra privileges for the top elite
)
# Initialize and run the genetic algorithm
if __name__ == "__main__":
genetic_algo = GeneticAlgorithm(
training_data=combined_df,
target="Target Over 5",
columns_to_drop=[
"Sample Column 1",
"Sample Column 2",
"Target" # Exclude target column from queries
],
genetic_params=genetic_params,
)
genetic_algo.run()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dynamic_genetic_algo-2.0.1.tar.gz.
File metadata
- Download URL: dynamic_genetic_algo-2.0.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cebc8e2d8899d55031563f8b2dbede33f669c523d00605bb80e224f5de220a5
|
|
| MD5 |
ce3f132ed09f3397748445bc162bf22f
|
|
| BLAKE2b-256 |
0362e35ce5b420e891b9ac4823cd15a6a767baa2ccf7797fbcfe8b13d08ad6b1
|
File details
Details for the file dynamic_genetic_algo-2.0.1-py3-none-any.whl.
File metadata
- Download URL: dynamic_genetic_algo-2.0.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0203f96b0deb2ed46c0dd38411d2293ce71821e3bcb9600465bebe5e8b1e784
|
|
| MD5 |
b522e6da1c72d9a1f0213d3808f77442
|
|
| BLAKE2b-256 |
ac7be1837aa177e29200f0fb1c870c26544e0c3c81f9d24bdcfaa4131d18feb0
|