A python package for ensembling machine learning predictions using hill climbing optimization
Project description
Hill Climbing
Hill climbing is a mathematical optimization algorithm that belongs to the family of local search techniques. It is commonly used to iteratively improve a solution based on a cost or objective function. This package provides a simple implementation of the hill climbing algorithm and is useful for efficiently blending predictions from multiple machine learning models. The goal is to achieve an ensemble score that is better than that of any single model in the ensemble.
How it works
Hill climbing starts with an initial solution, which is the predictions of one of the base models. It then iteratively explores neighboring solutions by adjusting the weights used to blend predictions from other models. If a new combination results in an improved value of the objective function, it becomes the current solution. This process repeats until no further improvement is possible, i.e. when a local optimum has been reached.
Installation
pip install hill-climbing
Example usage
from hill_climbing import Climber
from sklearn.metrics import root_mean_squared_error
# Running hill climbing
climber = Climber(
objective="minimize",
eval_metric=root_mean_squared_error
)
climber.fit(X, y)
print(f"Best score: {climber.best_score}")
print(f"Best predictions: {climber.best_oof_preds}")
# Predicting on unseen data
test_preds = climber.predict(X_test)
Example usage with cross-validation:
from hill_climbing import ClimberCV
from sklearn.metrics import root_mean_squared_error
from sklearn.model_selection import KFold
# Running hill climbing with CV
climber_cv = ClimberCV(
objective="minimize",
eval_metric=root_mean_squared_error,
cv=KFold(n_splits=5, shuffle=True, random_state=42)
)
climber_cv.fit(X, y)
print(f"Best score: {climber_cv.best_score}")
print(f"Best predictions: {climber_cv.best_oof_preds}")
# Predicting on unseen data
test_preds = climber_cv.predict(X_test)
Project details
Release history Release notifications | RSS feed
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 hill_climbing-0.1.4.tar.gz.
File metadata
- Download URL: hill_climbing-0.1.4.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
629c7f2570ac51e3eb24d0b96b28b755636c67c7e4af2599e877b27cc168865a
|
|
| MD5 |
23fa1190f217cfc03ac62d20db5ce560
|
|
| BLAKE2b-256 |
3c399370775b89cca90b75e74b7d9c1e332b029f4643cf91f3f42ee561b07b35
|
Provenance
The following attestation bundles were made for hill_climbing-0.1.4.tar.gz:
Publisher:
publish.yml on ravaghi/hill-climbing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hill_climbing-0.1.4.tar.gz -
Subject digest:
629c7f2570ac51e3eb24d0b96b28b755636c67c7e4af2599e877b27cc168865a - Sigstore transparency entry: 209329148
- Sigstore integration time:
-
Permalink:
ravaghi/hill-climbing@b596018c8d474f37769af279605061060b8b2f0b -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ravaghi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b596018c8d474f37769af279605061060b8b2f0b -
Trigger Event:
release
-
Statement type:
File details
Details for the file hill_climbing-0.1.4-py3-none-any.whl.
File metadata
- Download URL: hill_climbing-0.1.4-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9f9a74beb2821af227741a8f1cdc0a056e6ae2f34915a65eb7bc333d37670b1
|
|
| MD5 |
faadac735c238fc79311db860bfaf071
|
|
| BLAKE2b-256 |
5fcb3a63e0afc2d471cc760740b1a7a1578a90eca55b3791241b165e05a50fd6
|
Provenance
The following attestation bundles were made for hill_climbing-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on ravaghi/hill-climbing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hill_climbing-0.1.4-py3-none-any.whl -
Subject digest:
c9f9a74beb2821af227741a8f1cdc0a056e6ae2f34915a65eb7bc333d37670b1 - Sigstore transparency entry: 209329149
- Sigstore integration time:
-
Permalink:
ravaghi/hill-climbing@b596018c8d474f37769af279605061060b8b2f0b -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ravaghi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b596018c8d474f37769af279605061060b8b2f0b -
Trigger Event:
release
-
Statement type: