Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hill_climbing-0.1.5.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hill_climbing-0.1.5-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file hill_climbing-0.1.5.tar.gz.

File metadata

  • Download URL: hill_climbing-0.1.5.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

Hashes for hill_climbing-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3b188277aa584e1d8f230b8c61fb2d9880233f4ef118484129dbbc9bff7b1eb6
MD5 423583416eb08c7ae2fcb7e8cf75b43e
BLAKE2b-256 b34d2ae9514b551ebb4eb1cc977a16e640ef32b83e0e9ad6e74f28eec1edc587

See more details on using hashes here.

Provenance

The following attestation bundles were made for hill_climbing-0.1.5.tar.gz:

Publisher: publish.yml on ravaghi/hill-climbing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hill_climbing-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: hill_climbing-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hill_climbing-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8154404329c65da6496cfea3f19a4512a91bf67feb4f2ed47c33db47e8c5ec56
MD5 196f0b96726a63536caeb2ca6a4cfd34
BLAKE2b-256 1175a8840a955baffb73c591e1fd8f8a88130b9be6b78f21bbe1b7e2028f6554

See more details on using hashes here.

Provenance

The following attestation bundles were made for hill_climbing-0.1.5-py3-none-any.whl:

Publisher: publish.yml on ravaghi/hill-climbing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page