jra-tools
Sazanami-AIのデータ・学習のための道具。次の3つを持つ。
| 使い道 | モジュール | 主に使うところ |
|---|---|---|
| 学習・推論・評価の入力を作り、モデルを保存・読み込みする | jra_tools.machine_learning.features |
Jupyter・sazanami-batch |
| 分析用のPostgresのビューを反映する | jra_tools.views |
sazanami-batch・Jupyter |
| JRDBの取り込みの補助・開催日程の照合 | jra_tools(database/) |
sazanami-batch |
ドキュメント
| 何を知りたいか | どこ |
|---|---|
| 全体のどこにいて、何を持ち・持たないか、中の層 | docs/architecture.md |
| 仕様のYAML・ビューの列・テンソル・カテゴリ・モデルとモデルのフォルダの約束・ビューの反映 | docs/specification.md |
| 関数ごとの引数・戻り値 | APIリファレンス(下の「APIリファレンス」で生成) |
| 学習・評価・本採用の手順、モデルの置き場所 | 使う側のREADME(Jupyter: One-Stone/jupyter、推論: sazanami-batch) |
入れる
pip install "jra-tools[postgres]" # 分析用のPostgresから読むとき(ドライバのpsycopgも入る)
pip install jra-tools # JRDBの補助だけ
学習の入力を作る(例)
接続先は環境変数DB(分析用のPostgres。例: postgresql+psycopg://user:pass@host:5432/sazanami)。engineを作る必要はない。
from jra_tools.machine_learning import features
spec = features.pin_spec(features.load_feature_spec("spec.yaml")) # ビューのハッシュとカテゴリの番号を写す
dataset = features.load_dataset(spec, 20130101, 20241231) # dataset.x・dataset.labels
model.fit(dataset.x, dataset.labels) # Keras
features.save_model(model, spec, model_dir) # 推論できる形のモデルのフォルダ
modelは使う側が作るKerasのモデル(満たす約束はモデルの約束)。
ビューを反映する(例)
from jra_tools.views import apply_views, load_view_set
apply_views(engine, load_view_set("schemas")) # 定義が変わっていればビューを作り直す
定義のフォルダの形・反映の動きはビューの定義のフォルダと反映。
JRDB・開催日程
from jra_tools import ...で使う(sazanami-batchの取り込み・照合)。
| 名前 | 中身 |
|---|---|
annual_schedule・open_days・annual_kaisais・open_kaisais(async) |
Yahoo競馬の開催日・開催の一覧 |
missing_days・db_days |
DBに登録済みの開催日と、足りない日 |
get_kaisais(start, end) |
jrdb-modelの開催データを、紐づく表ごと読む |
BaoImporter |
BAOのオッズのCSVをDBに取り込む |
PredictRaceFactory |
推論するレースのデータを作る |
APIリファレンス
docstringから生成する(公開していない。手元で見る)。
uv run pdoc jra_tools.machine_learning.features jra_tools.views # ブラウザで開く
uv run pdoc jra_tools.machine_learning.features jra_tools.views -o site # HTMLに書き出す
テスト
uv run pytest
Postgresを使う結合テスト(tests/views・tests/machine_learning/test_integration_features.py・tests/machine_learning/interface_adapter/test_integration_view_gateway.py)は、環境変数TEST_POSTGRES(例: postgresql+psycopg://test_user:test_password@127.0.0.1:5432/test_database)がなければ飛ばす。テストはスキーマ(model・features・meta・staging・sandbox)を消して作り直すので、使い捨てのPostgresを指す。
Metadata
Release files for jra-tools 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jra_tools-0.8.0.tar.gz | 42.6 kB | With provenance | Details for jra_tools-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jra_tools-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for jra_tools-0.8.0-py3-none-any.whl |
Total release size: 98.1 kB
Release files / jra_tools-0.8.0.tar.gz
| Download URL | jra_tools-0.8.0.tar.gz |
|---|---|
| Size | 42.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55d53457bdd886107151b9d9263e44192029fccba62f98d8fb580a27d9297960
|
|
BLAKE2b-256 checksum How to use checksums |
e71c4fb79dfb6cf2190bdf33afbccaea52797bede367e362eb57f60cee8a9c8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logRelease files / jra_tools-0.8.0-py3-none-any.whl
| Download URL | jra_tools-0.8.0-py3-none-any.whl |
|---|---|
| Size | 55.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea627169fdd4ad237031c08dac6136022ec4a019000d9b062f030655e2e78230
|
|
BLAKE2b-256 checksum How to use checksums |
bd9e30c9f9aade8255523a424f386795a0053461904e411ef1636a075e06f53a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logSecurity for jra-tools 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for jra_tools-0.8.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.