التنبؤ على نص جديد تمامًا
نفّذ الاستدلال على مدخلات لم يرها النموذج
التنبؤ على نص جديد تمامًا درس مجاني في NLP Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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/7) وفتح باقي دورة NLP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة NLP Academy 4 دروس في المجموع.
ماذا ستتعلم في «التنبؤ على نص جديد تمامًا»؟
نفّذ الاستدلال على مدخلات لم يرها النموذج تتمرن على NLP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ NLP Academy؟
لا تُشترط خبرة سابقة. NLP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «التنبؤ على نص جديد تمامًا»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس NLP Academy هذا؟
نعم. كل درس في NLP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- هيكلة مشروع NLP حقيقي
- مسارات scikit-learn من البداية إلى النهاية
- حفظ النموذج وتحميله
- التنبؤ على نص جديد تمامًا