Term Deposit Prediction with MLflow and scikit-learn
GridSearchCV で定期預金モデルを調整し、すべての候補を MLflow で確認します。親実行、上位候補ごとの子実行、そして公正なテスト スコアを記録します。
- Python
- uv
- MLflow
- scikit-learn
- pandas
スクリーンショット
買い切り価格
- ₹149+GST(合計 ₹175.82)
- $3
- お支払いが確認されると、すぐにライブラリからダウンロードできます。
- このプロジェクトの今後のリリースもすべて、追加費用なしで含まれます。
- 最新リリース
- 1.0.0 · 2026/11/28
- ライセンス
- Source Code Licence
概要
MLflow 3.18 の自動ロギングで記録する、Python のハイパーパラメーター探索の完全なソース コードです。1 つのコマンドで勾配ブースティング モデルの設定 9 通りを試し、それぞれを 5 分割交差検証で評価し、上位 5 つを 1 つの親実行の下の子実行として保存し、探索で一度も使っていない顧客で勝者を評価します。
ハイパーパラメーター探索は大量の数字を生みますが、記録はほとんど残りません。Term Deposit Prediction with MLflow and scikit-learn は公開されている Bank Marketing データで scikit-learn のグリッド サーチを実行し、MLflow の自動ロギングですべての候補を残します。なぜその候補が勝ったのかを確認できます。
1 回の探索で記録されるもの
- 親実行。 探索自体の設定、最良の設定、最良の交差検証スコア、すべての候補のすべての分割での結果を収めた
cv_results.csv、学習データでの最良モデルの混同行列、ROC 曲線、適合率・再現率曲線のグラフ。 - 候補ごとの子実行。 上位 5 つの候補にそれぞれ実行が作られ、設定と、分割全体での平均、ばらつき、順位が記録されます。
- 公正なスコア。 通話の 20% は探索から外され、勝者はそのデータで評価されます。最初の探索のテスト ROC AUC は 0.8145 でした。
- 元になったコード。 探索を実行したコードの Git コミット。
実際に使えるモデル
- リークなし。 通話時間は通話が終わるまでわからないため、使いません。
- 整理されたパイプライン。 テキストの列を one-hot エンコードしてから
HistGradientBoostingClassifierで予測し、すべてを 1 つの scikit-learn パイプラインにまとめています。 - 検証済みのダウンロード。 データは一度だけダウンロードし、読み込む前に SHA-256 フィンガープリントを確認します。
拡張しやすいコード
- 整理された Python パッケージ。 uv で管理する
src構成で、コマンドはtuneの 1 つです。 - 設定を 1 か所に。 pydantic-settings が
.envを読み込み、.env.exampleがすべての設定を説明します。 - 正確なバージョン。
uv.lockがすべてのパッケージを固定します: MLflow 3.18.0、scikit-learn 1.9.1、pandas 3.1.1、Python 3.15。 - アーカイブにデータは含みません。 最初の実行でプロジェクトが公開データセットをダウンロードします。
含まれないもの
- 保存されたモデルはありません。 探索の目的は設定を選ぶことなので、自動ロギングはモデルを保存しません。
- ホスティングはありません。 1 つのコマンドで起動する MLflow トラッキング サーバーとともに、ご自身のコンピューターで動きます。
- テスト プロジェクトはありません。 上記の結果は実際の実行によるもので、アーカイブ内の自動テストによるものではありません。
6 つの手順で実行
- アーカイブを展開します。
- MLflow トラッキング サーバーを起動します。
.env.exampleを.envにコピーします。uv syncでパッケージをインストールします。- プロジェクトを Git に入れます。
uv run tuneで探索します。
README には macOS と Linux、PowerShell 用のすべてのコマンドがあります。How to Set Up and Run the Term Deposit Prediction Project (新しいタブで開きます)(英語)では、各手順と表示される内容を紹介しています。macOS 上でアーカイブのクリーンなコピーからテストしました。
作り方を学ぶ
無料のチュートリアル シリーズ MLflow Tutorial for Machine Learning in Python (新しいタブで開きます)(英語)の第 5 回で、このコードを使って自動ロギング、ネストされた実行、ハイパーパラメーター調整を解説しています。
無料チュートリアルシリーズ
MLflow Tutorial for Machine Learning in Python
作りながら学びたい方へ。ブログの無料ステップガイドで、このプロジェクトの作り方を順を追って紹介しています。
手に入るもの
アーカイブの中身が一目でわかります。
- 完全なソース コードのバージョン 1.0.0: uv で管理する Python パッケージ
- tune コマンド: 5 分割交差検証による 9 通りの設定のグリッド サーチ
- 探索を親実行と上位候補ごとの子実行として記録する MLflow の自動ロギング
- 探索で一度も使わないテスト データでの最良モデルの ROC AUC (親実行に記録)
- 勾配ブースティング分類器の前にテキストの列を one-hot エンコードする scikit-learn パイプライン
- 通話時間を除いた、公開 Bank Marketing データの検証済みダウンロード
- pydantic-settings による .env の設定と、説明付きの .env.example
- すべてのパッケージの正確なバージョンを記録した uv.lock
- macOS、Linux、PowerShell のセットアップ、探索、すべての設定、データセットのクレジットをまとめた README
使用している技術
開発と動作確認に使った実行環境とバージョンです。
- Python3.15.2
- uv0.13.10
- MLflow3.18.0
- scikit-learn1.9.1
- pandas3.1.1
- NumPy2.5.5
- pydantic-settings2.16.3
アーカイブの中身
展開したあとに手元に残るファイル構成です。
term-deposit-prediction-mlflow-scikit-learn/
- src/
- term_deposit_prediction/
- __init__.py
- code_version.py
- config.py
- data.py
- model.py
- tune.py
- term_deposit_prediction/
- .env.example
- .gitignore
- .python-version
- pyproject.toml
- uv.lock
- README.md
必要になるもの
動かすために必要なアカウントやサービスです。あとから驚くことはありません。
- Python 3.15 とパッケージをインストールしてくれる uv
- 各実行がコードのコミットを記録するための Git
- MLflow トラッキング サーバー: README の手順で、1 つのコマンドでお使いのコンピューターに起動できます
- 最初のインストール (約 550 MB のパッケージ) と、データをダウンロードする最初の探索のためのインターネット接続
リリース
これまでのすべてのバージョンを新しい順に並べています。
1.0.0最新
完全なソース コードの最初のリリースです。
- Bank Marketing データで、勾配ブースティング分類器の 9 通りの設定をグリッド サーチします。
- 探索を MLflow 3.18.0 の自動ロギングで記録します。親実行が 1 つ、上位 5 つの候補ごとに子実行が 1 つずつです。
- 探索で一度も使わないテスト データで最良のモデルを評価します。
- アーカイブから最初の記録済み探索までを案内する README を含みます。
Source Code Licence
利用できる範囲
What you may and may not do with the source code you buy.
ライセンスの全文を読む
- What this licence covers
This licence governs every file included in a product you buy from Dewiride Store: source code, configuration, database scripts, sample data, documentation and any other file in the download. It takes effect when your payment is confirmed and applies to every release of that product that reaches your library. Files that reach your library through an annual updates membership are governed in exactly the same way.
It forms part of the Terms of Sale and Use. Where a product page states different or additional licence terms for that product, those terms prevail for that product. The membership page may likewise state different or additional licence terms for the files a membership carries, and those terms then prevail for those files.
- The licence we grant you
We grant you a perpetual, worldwide, non-exclusive, non-transferable licence to use, reproduce, adapt, translate and modify the files, and to include the result in your own work, on the conditions set out below.
Perpetual means it does not expire. Worldwide means it is not limited to any country. Non-exclusive means we license the same product to other customers. Non-transferable means you cannot pass it on to someone else.
The licence is granted to you — either you personally, or the organisation you identified when buying. Everyone working within that organisation may use the files for that organisation’s projects. Nobody outside it may.
- What you may do
- Use and change the files in your own projects, commercial or otherwise, with no limit on the number of projects.
- Build a product or a service on them and charge your own customers for it.
- Deploy the result for a client, as part of work you are doing for that client.
- Distribute the result in compiled, deployed or otherwise non-source form.
- Keep as many back-up copies as you reasonably need.
- Study, observe and test how the code works, and obtain the information you need to make it work with your own software.
The last two are yours by law under sections 52(1)(aa) to (ac) of the Indian Copyright Act, 1957, and nothing in this licence is intended to take them away.
- What you may not do
- Resell, sublicense, redistribute or publish the files themselves, in whole or in substantial part, in source form.
- Include them in a template, starter kit, course, tutorial repository or component library that you sell or give away, where the code is the thing being supplied.
- Share your account, your download links or your invoices with anyone outside your organisation.
- Publish the files in a public repository, or in any other place where they can be obtained without buying them.
- Remove or obscure the copyright and attribution notices in the source files.
- Use the files to build something whose main purpose is to compete with Dewiride Store as a supplier of the same code.
The distinction that matters is simple: you may sell what you build with the code; you may not sell the code.
- Third-party components
Our products depend on open-source libraries, frameworks and services that we did not write. Those remain under their own licences, which we do not and cannot change. Where a product includes or requires such a component, its licence is named in the product’s documentation, and complying with it is your responsibility.
- Releases
Every release of a product you own is covered by this same licence and appears in your library at no extra cost. A release you have already downloaded remains licensed to you even if we later stop publishing the product. A release that reached your library through an annual updates membership is licensed to you on these same terms, and stays licensed after the period that carried it has ended.
- Ownership
We keep ownership of the files and of the copyright in them. You own whatever you create with them: your changes, your additions and the product you build are yours.
- If this licence ends
This licence ends if you materially breach it and do not put the breach right within thirty days of us asking you to in writing. It also ends if your payment is reversed or refunded, because the purchase it depends on no longer stands. Where a membership period is refunded or reversed, the licence ends for the releases that period carried and for nothing else: anything you bought separately, or that another period carried, is unaffected.
If it ends, you must stop using the files and delete the copies you hold. Work you had already delivered to a client before that point may continue in use, so that ending this licence never breaks something your own customer relies on.
- No warranty beyond the description
The warranties and limits in section 19 and section 20 of the Terms of Sale and Use apply to this licence as well.
- Governing law
This licence is governed by the law of India, and section 24 of the Terms of Sale and Use applies to any dispute about it. If a translation and the English version differ in meaning, the English version governs.
Term Deposit Prediction with MLflow and scikit-learn
- ₹149+GST(合計 ₹175.82)
- $3