0Pricing
NLP Academy · Lesson

Predicting on Brand-New Text

Run inference on unseen input.

Predicting on Brand-New Text is a free NLP Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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

Frequently asked questions

Is the “Predicting on Brand-New Text” lesson free?

Yes — the full text of “Predicting on Brand-New Text” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.

What will I learn in “Predicting on Brand-New Text”?

Run inference on unseen input. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start NLP Academy?

No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Predicting on Brand-New Text” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this NLP Academy lesson?

Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Structuring a Real NLP Project
  2. scikit-learn Pipelines End to End
  3. Saving and Loading Your Model
  4. Predicting on Brand-New Text
← Back to NLP Academy