まったく新しいテキストを予測する
未知の入力に対して推論を実行する
「まったく新しいテキストを予測する」はCoddyKit上の無料NLP Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはNLP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 NLP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Inference Time
Training is done. Now comes inference: feeding brand-new, unseen text to your saved model and reading back its prediction. 🚀
Load the Model First
Start every prediction script by loading the saved pipeline. From here it behaves exactly like the model you trained.
import joblib
model = joblib.load("models/sentiment.joblib")Predict Expects a List
The predict method takes a list of texts, not a single string. Even one example must be wrapped in a list.
model.predict(["the food was amazing"])Predict Many at Once
Pass a whole list to score many texts in one go. Batch prediction is far faster than looping one item at a time.
texts = ["loved it", "total waste of money"]
print(model.predict(texts))Get Probabilities
Want confidence, not just a label? Call predict_proba to see how sure the model is about each class.
model.predict_proba(["it was okay i guess"])Same Cleaning as Training
New text must go through the same cleaning as your training data. The pipeline handles this, which is exactly why you saved it whole.
Unknown Words Are Fine
Words the model never saw are simply ignored by the vectorizer. Your vocabulary is fixed at training time, so prediction stays stable.
Map Labels to Names
Models often return numbers like 0 and 1. Turn them into a readable label name so people can understand the output.
names = {0: "negative", 1: "positive"}
print(names[model.predict(["great"])[0]])Wrap It in a Function
Wrap loading and predicting in one helper function. Now any part of your app can classify text with a single clean call.
def classify(text):
return model.predict([text])[0]Watch for Drift
Real text changes over time. When accuracy slips, that is data drift, a signal it is time to retrain on fresh examples.
Serve It Anywhere
Your classify function can sit behind a web API or a script. The same saved model now powers real predictions in production. 🎯
Quick Check
Think about the input format predict requires.
Recap
You loaded the model, predicted on new text in batches, read probabilities, mapped labels, wrapped it in a function, and watched for drift. 🏁
よくある質問
「まったく新しいテキストを予測する」レッスンは無料ですか?
はい。「まったく新しいテキストを予測する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、NLP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 NLP Academyコースには全4レッスンが含まれています。
「まったく新しいテキストを予測する」で何を学びますか?
未知の入力に対して推論を実行する ブラウザで直接実行するハンズオンコードでNLP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
NLP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのNLP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「まったく新しいテキストを予測する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このNLP Academyレッスンでコードを書いて実行できますか?
はい。すべてのNLP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 実際の NLP プロジェクトを構成する
- scikit-learn パイプラインを最初から最後まで
- モデルを保存して読み込む
- まったく新しいテキストを予測する