名前とステージでモデルを読み込む
コードから現在のProductionモデルを取得します。
「名前とステージでモデルを読み込む」はCoddyKit上の無料MLOps Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMLOps Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MLOps Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Closing the Loop
Registering a model only pays off when code can load it back. This is where your serving app finally meets the registry. 🔁
The models URI
You fetch registered models through a models:/ URI. It names the model and which version or stage you want, no file paths required.
Load by Exact Version
For a pinned, reproducible load, ask for a specific version. This always returns the same artifact, which is great for tests.
import mlflow
m = mlflow.pyfunc.load_model(
"models:/churn-classifier/4")Load by Stage
In production you usually load by stage instead. Asking for Production means you always get whatever version is live right now.
m = mlflow.pyfunc.load_model(
"models:/churn-classifier/Production")Stage Loading Is Indirect
Loading by stage adds a layer of indirection. Promote a new version to Production and your code picks it up with no edits or redeploy.
Load by Alias
If you use aliases, load with the @ syntax. Asking for the champion alias resolves to whichever version you tagged as champion.
m = mlflow.pyfunc.load_model(
"models:/churn-classifier@champion")pyfunc Is Universal
The pyfunc flavor wraps any framework behind one predict method. Your serving code stays identical whether it is sklearn or PyTorch underneath.
preds = m.predict(input_df)Native Flavor When Needed
Need framework-specific methods? Load the native flavor instead, like mlflow.sklearn, to get the original estimator object back.
model = mlflow.sklearn.load_model(
"models:/churn-classifier/Production")Point at the Server
Loading needs the tracking URI set so MLflow knows which registry to query. Without it, the lookup fails or hits the wrong store.
mlflow.set_tracking_uri(
"http://localhost:5000")Load Once at Startup
Loading is expensive, so do it once when your service boots, not on every request. Reuse the same object across predictions.
Refresh to Pick Up Changes
A long-running service keeps the version it loaded at startup. To adopt a freshly promoted model, reload on a schedule or restart the service.
Quick Check
Decide which URI a long-lived service should load.
Recap
You loaded models with a models:/ URI by version, stage, or alias, and learned to load once at startup. The registry round-trip is complete. 🚀
よくある質問
「名前とステージでモデルを読み込む」レッスンは無料ですか?
はい。「名前とステージでモデルを読み込む」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MLOps Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MLOps Academyコースには全4レッスンが含まれています。
「名前とステージでモデルを読み込む」で何を学びますか?
コードから現在のProductionモデルを取得します。 ブラウザで直接実行するハンズオンコードでMLOps Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MLOps Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMLOps Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「名前とステージでモデルを読み込む」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMLOps Academyレッスンでコードを書いて実行できますか?
はい。すべてのMLOps Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 最初のモデルバージョンを登録する
- ステージ:Staging、Production、Archived
- モデルにタグと説明を追加する
- 名前とステージでモデルを読み込む