Skip to main content

Thompson Sampling using bootstrap sampling

Project description

Galileo Forecast

Galileo Forecast is a Python package that implements Thompson Sampling. It provides a flexible wrapper that can be used with various base model classes.

Installation

You can install Galileo Forecast using pip:

pip install galileo-forecast

Usage

To use Galileo Forecast, you need to create a wrapper for your base model class. Here's an example with LightGBM:

from galileo_forecast import ThompsonSamplingWrapper
from lightgbm import LGBMClassifier

# make classification data, us sklearn make_classification
from sklearn.datasets import make_classification

# sample data with low hit rate
X, y = make_classification(n_samples=1000, n_features=10, n_informative=1, n_redundant=1, n_clusters_per_class=1, class_sep=0.1)

# create a wrapper for the LightGBM model  
wrapper = ThompsonSamplingWrapper(base_model_class=LGBMClassifier, num_models=10)

# fit the wrapper
wrapper.fit(X, y)

# get the predicted probabilities for the positive class
selected_model_indices, sampled_probabilities = wrapper.predict_proba(X)

# get the fancy output dataframe - contains sampled probabilities, the sampled model and the greedy model, etc.
print(wrapper.get_fancy_output_df().head())

Demo

The demo folder contains Jupyter notebooks that shows how to use the package.

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

galileo_forecast-0.1.4.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

galileo_forecast-0.1.4-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file galileo_forecast-0.1.4.tar.gz.

File metadata

  • Download URL: galileo_forecast-0.1.4.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.1 Darwin/23.5.0

File hashes

Hashes for galileo_forecast-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6b6679e3f81512eef9355d1772877762768805c669da17b3ce5323694a8bc2e8
MD5 cad3f875431d9e4927190bf561eb51ce
BLAKE2b-256 7dce8c3b2e16bdb3f84ca0002c57b597631d3ee290149576b3217bb373a6164d

See more details on using hashes here.

File details

Details for the file galileo_forecast-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: galileo_forecast-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.1 Darwin/23.5.0

File hashes

Hashes for galileo_forecast-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 709092140b5da79b0afc710a8b9f6c66942ce6abdbdb33258b6d0ef945c98610
MD5 1feae174adb00dd968eca9b06f6e9bd3
BLAKE2b-256 0fe19190bf0321a7ccb7051daf2603612ab5d287a298f01ab5ead805d4d03d34

See more details on using hashes here.

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