evolutune


Nameevolutune JSON
Version 0.0.3 PyPI version JSON
download
home_page
SummaryA Genetic Algorithm-based hyperparameter tuner for machine learning models.
upload_time2024-03-05 16:19:29
maintainer
docs_urlNone
authortorchd3v
requires_python
license
keywords python hyperparameter tuning genetic-algorithm model search cv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Evolutune
A Genetic Algorithm-based hyperparameter tuner for machine learning models.

## Introduction
Evolutune, implements a hyperparameter tuner based on the principles of a genetic algorithm. The genetic algorithm evolves a population of hyperparameter sets over several generations, aiming to find the set that optimizes a given scoring metric. This tuner is designed to work with various machine learning models.

## Dependencies
Make sure you have the following dependencies installed:

- ```numpy```
- ```joblib.Parallel``` and ```joblib.delayed```
- ```sklearn.metrics.get_scorer```

## Installation
```sh
pip install evolutune
```

## Usage
```python3
from evolutune import GeneticTuner

# Define your machine learning model
# model = ...

# Define the hyperparameter search space
param_grid = {
    'param1': [value1, value2, ...],
    'param2': [value3, value4, ...],
    # Add more hyperparameters as needed
}

# Define the scoring metric to optimize
scoring_metric = 'accuracy'  # Replace with your preferred metric

# Instantiate the GeneticTuner
genetic_tuner = GeneticTuner(
    model=model,
    param_grid=param_grid,
    scoring=scoring_metric,
    population_size=10,
    generations=100,
    mutation_rate=0.1,
    random_state=None,
    n_jobs=None
)
```

## Fitting the Tuner
```python3
# Define your training and evaluation sets
train_set = [X_train, y_train]
eval_set = [X_eval, y_eval]  # Set to None to use the training set for evaluation

# Specify the optimization direction ('maximize' or 'minimize')
direction = 'maximize'

# Fit the tuner on the training set
genetic_tuner.fit(train_set, eval_set, direction)
```

## Accessing Results
```python3
# Access the best score and corresponding hyperparameters
best_score = genetic_tuner.best_score_
best_params = genetic_tuner.best_params_

print(f"Best Score: {best_score}")
print("Best Hyperparameters:")
for param, value in best_params.items():
    print(f"{param}: {value}")
```

## Methods

| Method                                                                          | Description                                                           |
|---------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `initialize_population(population_size: int) -> list`                           | Initialize a population of individuals with random hyperparameters.   |
| `crossover(parent1: dict, parent2: dict) -> tuple`                              | Perform crossover between two parents to generate two children.       |
| `mutate(individual: dict, mutation_rate: float) -> dict`                        | Introduce random mutations to an individual's hyperparameters.        |
| `calculate_fitness(train_set: list, eval_set: list, parameters: dict) -> float` | Evaluate the fitness (scoring metric) of a set of hyperparameters.    |
| `fit(train_set: list, eval_set: list = None, direction: str = "maximize")`      | Fit the GeneticTuner on the training set and optional evaluation set. |


## Example
An example script demonstrating the usage of the GeneticTuner class is provided in the example.py file.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "evolutune",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,hyperparameter,tuning,genetic-algorithm,model,search,CV",
    "author": "torchd3v",
    "author_email": "<burak96egeli@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/06/31/7b44ef24b2e12a34d120048850068145b672c04812f985311ea8e5591392/evolutune-0.0.3.tar.gz",
    "platform": null,
    "description": "# Evolutune\nA Genetic Algorithm-based hyperparameter tuner for machine learning models.\n\n## Introduction\nEvolutune, implements a hyperparameter tuner based on the principles of a genetic algorithm. The genetic algorithm evolves a population of hyperparameter sets over several generations, aiming to find the set that optimizes a given scoring metric. This tuner is designed to work with various machine learning models.\n\n## Dependencies\nMake sure you have the following dependencies installed:\n\n- ```numpy```\n- ```joblib.Parallel``` and ```joblib.delayed```\n- ```sklearn.metrics.get_scorer```\n\n## Installation\n```sh\npip install evolutune\n```\n\n## Usage\n```python3\nfrom evolutune import GeneticTuner\n\n# Define your machine learning model\n# model = ...\n\n# Define the hyperparameter search space\nparam_grid = {\n    'param1': [value1, value2, ...],\n    'param2': [value3, value4, ...],\n    # Add more hyperparameters as needed\n}\n\n# Define the scoring metric to optimize\nscoring_metric = 'accuracy'  # Replace with your preferred metric\n\n# Instantiate the GeneticTuner\ngenetic_tuner = GeneticTuner(\n    model=model,\n    param_grid=param_grid,\n    scoring=scoring_metric,\n    population_size=10,\n    generations=100,\n    mutation_rate=0.1,\n    random_state=None,\n    n_jobs=None\n)\n```\n\n## Fitting the Tuner\n```python3\n# Define your training and evaluation sets\ntrain_set = [X_train, y_train]\neval_set = [X_eval, y_eval]  # Set to None to use the training set for evaluation\n\n# Specify the optimization direction ('maximize' or 'minimize')\ndirection = 'maximize'\n\n# Fit the tuner on the training set\ngenetic_tuner.fit(train_set, eval_set, direction)\n```\n\n## Accessing Results\n```python3\n# Access the best score and corresponding hyperparameters\nbest_score = genetic_tuner.best_score_\nbest_params = genetic_tuner.best_params_\n\nprint(f\"Best Score: {best_score}\")\nprint(\"Best Hyperparameters:\")\nfor param, value in best_params.items():\n    print(f\"{param}: {value}\")\n```\n\n## Methods\n\n| Method                                                                          | Description                                                           |\n|---------------------------------------------------------------------------------|-----------------------------------------------------------------------|\n| `initialize_population(population_size: int) -> list`                           | Initialize a population of individuals with random hyperparameters.   |\n| `crossover(parent1: dict, parent2: dict) -> tuple`                              | Perform crossover between two parents to generate two children.       |\n| `mutate(individual: dict, mutation_rate: float) -> dict`                        | Introduce random mutations to an individual's hyperparameters.        |\n| `calculate_fitness(train_set: list, eval_set: list, parameters: dict) -> float` | Evaluate the fitness (scoring metric) of a set of hyperparameters.    |\n| `fit(train_set: list, eval_set: list = None, direction: str = \"maximize\")`      | Fit the GeneticTuner on the training set and optional evaluation set. |\n\n\n## Example\nAn example script demonstrating the usage of the GeneticTuner class is provided in the example.py file.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Genetic Algorithm-based hyperparameter tuner for machine learning models.",
    "version": "0.0.3",
    "project_urls": null,
    "split_keywords": [
        "python",
        "hyperparameter",
        "tuning",
        "genetic-algorithm",
        "model",
        "search",
        "cv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8510ecb229951c647789580d777e413d0a42d6e68872d92d65c22c5adf4bfb0e",
                "md5": "0b12ab13bfc64f0f3f314015f0450878",
                "sha256": "0e625cc7a46c9cd5761297ba5a2fef6bdb59a47fd3ebf1c1af114dd208e37d9d"
            },
            "downloads": -1,
            "filename": "evolutune-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b12ab13bfc64f0f3f314015f0450878",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9289,
            "upload_time": "2024-03-05T16:19:28",
            "upload_time_iso_8601": "2024-03-05T16:19:28.971467Z",
            "url": "https://files.pythonhosted.org/packages/85/10/ecb229951c647789580d777e413d0a42d6e68872d92d65c22c5adf4bfb0e/evolutune-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06317b44ef24b2e12a34d120048850068145b672c04812f985311ea8e5591392",
                "md5": "1f2c1628faf7f5ee3723b3b76095d71f",
                "sha256": "a7c782e20709b1d3419a536e5939ba6bff43c27438abd06ed273312cf22ce780"
            },
            "downloads": -1,
            "filename": "evolutune-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "1f2c1628faf7f5ee3723b3b76095d71f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8713,
            "upload_time": "2024-03-05T16:19:29",
            "upload_time_iso_8601": "2024-03-05T16:19:29.933783Z",
            "url": "https://files.pythonhosted.org/packages/06/31/7b44ef24b2e12a34d120048850068145b672c04812f985311ea8e5591392/evolutune-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-05 16:19:29",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "evolutune"
}
        
Elapsed time: 0.62175s