Skip to main content

ShimaenagaBoost: Attentive Histogram GBDT with sample-level token attention

Project description

ShimaenagaBoost

Attentive Histogram GBDT — サンプル単位のトークン注意機構を備えた勾配ブースティング

ShimaenagaBoost は、LightGBM スタイルのヒストグラムベース GBDT に、サンプルごとの トークン注意機構(attention)を組み込んだ機械学習ライブラリです。特徴量を 「トークン」と呼ぶサブセットに分割して各トークンごとに木を成長させ、 サンプルごとに学習された注意重みでそれらを混合します。これにより、 純粋な GBDT では捉えにくい特徴グループ間の相互作用を表現できます。


インストール

必要環境

  • C++17 コンパイラ(GCC ≥ 9, Clang ≥ 11, MSVC 2019 以降)
  • CMake ≥ 3.20
  • Python ≥ 3.8 + NumPy
  • scikit-learn(sklearn 互換 API と examples の実行に使用)
  • (オプション)pybind11 — ネイティブ拡張としてビルドする場合のみ

Python パッケージの利用

pip install shimaenagaboost

クイックスタート

from shimaenagaboost import ShimaenagaBoostRegressor, ShimaenagaBoostClassifier, ShimaenagaBoostRanker

回帰

from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from shimaenagaboost import ShimaenagaBoostRegressor

data = fetch_california_housing()
X_train, X_test, y_train, y_test = train_test_split(
    data.data, data.target, test_size=0.2, random_state=42
)

model = ShimaenagaBoostRegressor(
    tier=1,             # Tier-1: Attentive Readout
    num_tokens=4,       # 特徴を 4 グループに分割
    num_heads=2,        # 注意ヘッド数
    d_attn=4,           # 注意埋め込み次元
    num_iterations=300,
    learning_rate=0.05,
)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)

二値分類

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from shimaenagaboost import ShimaenagaBoostClassifier

data = load_breast_cancer()
X_train, X_test, y_train, y_test = train_test_split(
    data.data, data.target, test_size=0.2, random_state=42
)

clf = ShimaenagaBoostClassifier(
    num_class=1,        # 1 = 二値(既定)
    tier=1,
    num_tokens=4,
    num_iterations=200,
)
clf.fit(X_train, y_train)
proba = clf.predict_proba(X_test)   # shape (n, 2)
labels = clf.predict(X_test)

多クラス分類

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from shimaenagaboost import ShimaenagaBoostClassifier

data = load_iris()
X_train, X_test, y_train, y_test = train_test_split(
    data.data, data.target, test_size=0.2, random_state=42
)

clf = ShimaenagaBoostClassifier(
    num_class=3,        # K クラス softmax
    tier=1,
    num_tokens=2,
    num_iterations=100,
)
clf.fit(X_train, y_train)
proba = clf.predict_proba(X_test)   # shape (n, 3)

ランキング(LambdaMART)

from shimaenagaboost import ShimaenagaBoostRanker

# group: クエリごとのサンプル数(合計 = len(X_train))
model = ShimaenagaBoostRanker(tier=1, num_iterations=200)
model.fit(X_train, y_train, group=group_train)
scores = model.predict(X_test)

# 検証セット付き(eval_group 必須 — valid の NDCG をクエリ単位で計算するため)
model.fit(X_train, y_train, group=group_train,
          eval_set=[(X_valid, y_valid)], eval_group=[group_valid],
          early_stopping_rounds=50)

モデルの保存・ロード

model.save_model("model.sbb")       # バイナリ形式 (.sbb, 形式 v3)

# ロード: 同じ設定でインスタンスを作り、一度 fit で booster を初期化してから load
loaded = ShimaenagaBoostRegressor(tier=1, num_tokens=4)
loaded.fit(X_tiny, y_tiny)          # booster の初期化(小さなデータで可)
loaded.load_model("model.sbb")
pred = loaded.predict(X_test)

ライセンス

MIT License.
詳細は LICENSE を参照してください。
サードパーティの著作権表示は THIRD_PARTY_NOTICES.md を参照してください。

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

shimaenagaboost-0.1.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distributions

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

shimaenagaboost-0.1.0-cp313-cp313-win_amd64.whl (372.2 kB view details)

Uploaded CPython 3.13Windows x86-64

shimaenagaboost-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl (583.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

shimaenagaboost-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (378.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

shimaenagaboost-0.1.0-cp312-cp312-win_amd64.whl (372.2 kB view details)

Uploaded CPython 3.12Windows x86-64

shimaenagaboost-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl (583.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

shimaenagaboost-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (378.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

shimaenagaboost-0.1.0-cp311-cp311-win_amd64.whl (368.6 kB view details)

Uploaded CPython 3.11Windows x86-64

shimaenagaboost-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl (581.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

shimaenagaboost-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (376.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

shimaenagaboost-0.1.0-cp310-cp310-win_amd64.whl (367.0 kB view details)

Uploaded CPython 3.10Windows x86-64

shimaenagaboost-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl (579.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

shimaenagaboost-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (375.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

shimaenagaboost-0.1.0-cp39-cp39-win_amd64.whl (367.2 kB view details)

Uploaded CPython 3.9Windows x86-64

shimaenagaboost-0.1.0-cp39-cp39-manylinux_2_28_x86_64.whl (580.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

shimaenagaboost-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (375.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file shimaenagaboost-0.1.0.tar.gz.

File metadata

  • Download URL: shimaenagaboost-0.1.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shimaenagaboost-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2595d4e6aca19f183654be70efe3b84578b74f3acb181cafea993f9dc0f95f20
MD5 a6f0f1db77db5c1f8f18a801c7f7ddcf
BLAKE2b-256 96162d598e10b9562a76ec9d70beeabc23aac983a3c6a16bb5a905158ff44518

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0.tar.gz:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f7045725073183e77d495e0a2217926d0b8b0aa64a98da4dd7aeea740a7260bb
MD5 be9b544ccb1d16dd7f822dae3e4b50c7
BLAKE2b-256 872ccd2b8a9d69846b5e453ce12ca96f85859f3ec40d2d3a89db8cbf43f60f8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d8e4ac2751c863d30991476f4b84d83c36dfd7b112dd213f0e7166b3a991e19e
MD5 3435eab2b6c0a908a5994238352e5a6c
BLAKE2b-256 11508ed81e3c171e84206ac1dc0cb7d71d429ca7b8c406ddfe3fcfbe5ac29a56

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3e81a269ef742ca4c9d9f8db2867e4f1ef4e78f847a04accdccd7bbce2efe7a
MD5 97e49ad52170aad309437298183ac730
BLAKE2b-256 00bb3c423ce340f58bc4cd88105d77a3d2d7df80b9c6ce55216af2d19a08c56d

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e27aa804169c9a0af630f7b8ab042bc07cc0440c8bc954a38877baed9b814914
MD5 b409e233860b0acf939406312b334788
BLAKE2b-256 ccd17af9b5cb7acd3a6feacda55107a09ff1b803a9ad003d5649211c4259500a

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dce151eecbfc4ead236830ca61b75916984f932f288ee6312a6ee9bdd5bebe2a
MD5 8d10384641ad03815287e62ccd8a1cba
BLAKE2b-256 1675a863057d1238abd4b927863349c20eee5908722744ca4c86c1cc56be98ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea51a0036c265543cdcbfa5a12e727462b421630c158cac7208c1bae915fb9c5
MD5 28497c67047d7489e7b52e90cd4e6dc0
BLAKE2b-256 0c5196d3941c5ab5bda82016db970f165c15f3b55ff708e0b25539ea148643f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cd1153e44b31c6c02693c2f47cbc399abcc2556af93407c1f129161043543aff
MD5 a596565768b3d31e78cd306b56de1107
BLAKE2b-256 6bf831c233dc04594ac09455e86412a0e0cc69472001977e3cde884dded06875

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa502596c682b792a90efa59f4dcdf91097eda2c04d0fdf95b0e72449619adcc
MD5 faa06d2343dcf7bb367c05ee91cd2cb7
BLAKE2b-256 f3124abffcdecdf7e86681eda5eff2956646cb3edda8d80f123e88b3635b6362

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4df844491b28db1d9692d879f84df7930a783ef111a2894dc3ffc5d12c0ee3c3
MD5 1c219717a37670fe7442c3240230eaab
BLAKE2b-256 1d4d4fb10557ac45a7ee94e27de91fed94bc49d1fe436159715227dafec28e50

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a31dcb781514e696526301840866fa25548d26bd08751d235b502e7b80d7f164
MD5 b8766926c329a5bdf5de2f994b9b6f7c
BLAKE2b-256 54ae8af85c058e23134c852a7ff77142723c4198d9a8fec902127ec4754656de

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp310-cp310-win_amd64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8c02e966aa2008757857f4e3e172fb54f9207eeef8846700a2bcb41c79c04aa3
MD5 c37f25b4e3a60c02275cfa980480fbda
BLAKE2b-256 9ac700b46d4e2d2e2329385994606f9fced602ea28c932892af7cdc4928074be

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d64a5de6efb71af4c6e151c01ee9d6fbfa3c526d6b11c3f5f5ec56cef9befdea
MD5 d8536fc6c0695840fc7e2f60ed232287
BLAKE2b-256 2252073cda4a90ee5066c1ed71d5b0e9a5b017925ea759edc60f03196c53db08

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d54c0e022b8a83811adf864f23e480902874b7f78fa9c76410f7c5b74b5bf60b
MD5 dde1019f9e8f72db3086a5c4661e6c78
BLAKE2b-256 7c4728e916c5e80a3b29e98da249c1baacb148dfafc2487e2be5645156dd05c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp39-cp39-win_amd64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6aa537b5ed90c172c1eddaafeac4738170a5d7ea1dce219a93832ddd6bb4c254
MD5 370f3442e5603c3e6b9b56ac16addbd5
BLAKE2b-256 8a2d8894923d3564ac7dd6c1bb7511299e80064c10f37cc2b1fd11a9b4406964

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp39-cp39-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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

File details

Details for the file shimaenagaboost-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for shimaenagaboost-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 223a60c9f118abda075ace10fb258ba6aeadfbfb16ca7598c1f20c83f8180ee2
MD5 0f6a1056881c2b8689dfa576bb2ab386
BLAKE2b-256 ff40ac1ebb54ac717db3b7d4952760f40dfbb540d78221f52e6aa103b5fe7798

See more details on using hashes here.

Provenance

The following attestation bundles were made for shimaenagaboost-0.1.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: pypi.yml on shota-iwamoto/ShimaenagaBoost

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