メインコンテンツへ移動

House Price Prediction with MLflow and scikit-learn

scikit-learn でカリフォルニアの住宅価格モデルを学習し、すべての実行を MLflow で追跡します。各ステップのスコア、システム メトリクス、正確なデータ、グラフを記録します。

  • Python
  • uv
  • MLflow
  • scikit-learn
  • pandas

スクリーンショット

スクリーンショット 1 / 6:タイトル カード: House Price Prediction、MLflow 用の Python ソース コード。技術の一覧と、検証 RMSE が 10 本で 0.5490 から 100 本で 0.5276 に下がるターミナルがあります。

タイトル カード: House Price Prediction、MLflow 用の Python ソース コード。技術の一覧と、検証 RMSE が 10 本で 0.5490 から 100 本で 0.5276 に下がるターミナルがあります。

買い切り価格

  • ₹249+GST(合計 ₹293.82)
  • $5
  • お支払いが確認されると、すぐにライブラリからダウンロードできます。
  • このプロジェクトの今後のリリースもすべて、追加費用なしで含まれます。
最新リリース
1.0.0 · 2026/11/28
ライセンス
Source Code Licence

概要

MLflow 3.18 で最初から最後まで追跡する、Python の住宅価格モデルの完全なソース コードです。各学習実行は、設定、10 本ごとの検証スコア、テスト スコア、CPU とメモリの使用量、学習に使ったデータ、予測値と実際の値のグラフ、Git コミットを記録します。2 つのコマンドで、実行をランキングと学習曲線として読み返せます。

モデルの価値は、それをどう作ったかを覚えていられるかで決まります。House Price Prediction with MLflow and scikit-learn は California Housing データで scikit-learn のランダム フォレストを学習し、すべての実行のすべてを MLflow に記録させます。推測ではなく、実行どうしを比べて判断できます。

各実行が記録するもの

  • 設定。 木の数、深さ、各分割のサイズ、シードを MLflow のパラメーターとして記録します。
  • 各ステップのスコア。 フォレストは 10 本ずつ成長し、ステップごとに検証用の行で評価されるため、MLflow が学習曲線を描きます。
  • テスト スコア。 学習で一度も使っていない行での MAE、RMSE、R²。最初の実行の RMSE は 0.516 で、一般的な住宅で約 51,600 ドルの誤差です。
  • コンピューターの負荷。 CPU、メモリ、ディスク、ネットワークの使用量を毎秒記録します。
  • 正確なデータ。 学習、検証、テストの行を MLflow のデータセットとして記録し、それぞれにデータが変わると変わるダイジェストが付きます。
  • 根拠。 予測値と実際の値のグラフ、各特徴量の重要度、すべてのテスト予測を収めた CSV ファイル、モデルの全設定。
  • 元になったコード。 その実行を生んだコードの Git コミット。

実行を読み返す

  • leaderboard は完了した実行を検証 RMSE の順に並べます。MLflow の検索フィルターも指定できます。
  • curve は 1 つの実行のステップごとのスコアと、最も良かったステップを表示します。

拡張しやすいコード

  • 整理された Python パッケージ。 uv で管理する src 構成で、train、curve、leaderboard の 3 つのコマンドがあります。
  • 設定を 1 か所に。 pydantic-settings が .env を読み込み、.env.example がすべての設定を説明します。
  • 正確なバージョン。 uv.lock がすべてのパッケージを固定します: MLflow 3.18.0、scikit-learn 1.9.1、pandas 3.1.1、Python 3.15。
  • アーカイブにデータは含みません。 最初の実行で scikit-learn が公開データセットをダウンロードします。

含まれないもの

  • ホスティングはありません。 1 つのコマンドで起動する MLflow トラッキング サーバーとともに、ご自身のコンピューターで動きます。
  • テスト プロジェクトはありません。 上記の結果は実際の実行によるもので、アーカイブ内の自動テストによるものではありません。

6 つの手順で実行

  1. アーカイブを展開します。
  2. MLflow トラッキング サーバーを起動します。
  3. .env.example を .env にコピーします。
  4. uv sync でパッケージをインストールします。
  5. プロジェクトを Git に入れます。
  6. uv run train で学習します。

README には macOS と Linux、PowerShell 用のすべてのコマンドがあります。How to Set Up and Run the House Price Prediction Project (新しいタブで開きます)(英語)では、各手順と表示される内容を紹介しています。macOS 上でアーカイブのクリーンなコピーからテストしました。

作り方を学ぶ

無料のチュートリアル シリーズ MLflow Tutorial for Machine Learning in Python (新しいタブで開きます)(英語)の第 1 回から第 4 回で、このコードを使ってトラッキング サーバー、時系列のメトリクス、システム メトリクス、アーティファクト、データセット、実行の検索を解説しています。

無料チュートリアルシリーズ

MLflow Tutorial for Machine Learning in Python

作りながら学びたい方へ。ブログの無料ステップガイドで、このプロジェクトの作り方を順を追って紹介しています。

シリーズを読む (新しいタブで開きます)

手に入るもの

アーカイブの中身が一目でわかります。

  • 完全なソース コードのバージョン 1.0.0: uv で管理する Python パッケージ
  • train コマンド: 10 本ずつ成長するランダム フォレスト。各ステップで検証スコア、最後にテスト スコアを記録します
  • パラメーター、ステップごとのメトリクス、テスト メトリクス、システム メトリクス、データセット、グラフ、2 つの表、Git コミットの MLflow での追跡
  • 実行を並べる leaderboard コマンド (MLflow の検索フィルターも指定可能)
  • 実行の学習曲線と最良のステップを表示する curve コマンド
  • 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
  • Matplotlib3.11.2
  • pydantic-settings2.16.3
  • psutil7.2.2

アーカイブの中身

展開したあとに手元に残るファイル構成です。

house-price-prediction-mlflow-scikit-learn/

  • src/
    • house_price_prediction/
      • __init__.py
      • code_version.py
      • config.py
      • curve.py
      • data.py
      • datasets.py
      • leaderboard.py
      • plots.py
      • reports.py
      • train.py
  • .env.example
  • .gitignore
  • .python-version
  • pyproject.toml
  • uv.lock
  • README.md

必要になるもの

動かすために必要なアカウントやサービスです。あとから驚くことはありません。

  • Python 3.15 とパッケージをインストールしてくれる uv
  • 各実行がコードのコミットを記録するための Git
  • MLflow トラッキング サーバー: README の手順で、1 つのコマンドでお使いのコンピューターに起動できます
  • 最初のインストール (約 550 MB のパッケージ) と、データをダウンロードする最初の実行のためのインターネット接続

リリース

これまでのすべてのバージョンを新しい順に並べています。

  1. 1.0.0最新

    完全なソース コードの最初のリリースです。

    • California Housing データで scikit-learn のランダム フォレストを学習し、すべての実行を MLflow 3.18.0 で追跡します。
    • 設定、各ステップの検証スコア、テスト スコア、システム メトリクス、データセット、グラフ、2 つの表、Git コミットを記録します。
    • 実行を読み返す 2 つのコマンド、ランキングと学習曲線を追加します。
    • アーカイブから最初の追跡済み実行までを案内する README を含みます。

Source Code Licence

利用できる範囲

What you may and may not do with the source code you buy.

ライセンスの全文を読む
  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.