📋 المحتوى المنظم
📖 محتوى تعليمي مفصّل
نوع: محتوى تعليمي
يمكن الآن إدخال أداة التمثيل بالمتجهات في مصنف بايز الساذج لبناء خط أنابيب نموذج تنبؤ جديد وتطبيقه على بيانات اختبار IMDb:
نوع: محتوى تعليمي
# train a new Naive Bayes Classifier on the newly vectorized data.
model_tf =MultinomialNB()
model_tf.fit(X_train_v2, Y_train)
# create a new prediction pipeline.
prediction_pipeline_tf = make_pipeline(vectorizer_tf, model_tf)
# get predictions using the new pipeline.
predictions_tf = prediction_pipeline_tf.predict(X_test_text_annotated)
# print the achieved accuracy.
accuracy_score(Y_test, predictions_tf)
نوع: محتوى تعليمي
0.8858
نوع: محتوى تعليمي
يحقق خط الأنابيب الجديد دقة تصل إلى 88.58%، وهو تحسن كبير بالمقارنة مع الدقة السابقة التي وصلت إلى 84.68%. يمكن الآن استخدام النموذج المحسن لإعادة النظر في مثال الاختبار الذي تم تصنيفه بشكل خاطئ بواسطة النموذج الأول:
نوع: محتوى تعليمي
# get the review example that confused the previous algorithm
mistake_example_annotated=X_test_text_annotated[4600]
print('\nReview:', mistake_example_annotated)
# get the correct labels of this example.
print('\nCorrect Label:', class_names[Y_test[4600]])
# get the prediction probabilities for this example.
print('\nPrediction Probabilities for neg, pos:',prediction_pipeline_tf.predict_proba([mistake_example_annotated]))
نوع: محتوى تعليمي
Review: i_personally thought the movie was_pretty good very_good acting by tadanobu_ asano of ichi_the_killer fame i really can_t say much about the story but there_were parts that confused me a little_too much and overall i_thought the movie was just too lengthy other_than that however the movie contained superb_acting great fightings and a lot of the locations were beautifully_shot great effects and a lot of sword play another solid effort by tadanobu_asano in my_opinion well i really can_t say anymore about the movie but if_you re only outlook on asian_cinema is crouching_tiger hidden_ dragon or house of flying_daggers i_would suggest_you trying to rent_it but if_you re a die_hard asian_cinema fan i_would say this has to be in your_collection very_good japanese film
نوع: محتوى تعليمي
Correct Label: pos
نوع: محتوى تعليمي
Prediction Probabilities for neg, pos: [[0.32116538 0.67883462]]
نوع: METADATA
150
نوع: METADATA
وزارة التعليم
Ministry of Education
2023 - 1447
📄 النص الكامل للصفحة
يمكن الآن إدخال أداة التمثيل بالمتجهات في مصنف بايز الساذج لبناء خط أنابيب نموذج تنبؤ جديد وتطبيقه على بيانات اختبار IMDb:# train a new Naive Bayes Classifier on the newly vectorized data.
model_tf =MultinomialNB()
model_tf.fit(X_train_v2, Y_train)# create a new prediction pipeline.
prediction_pipeline_tf = make_pipeline(vectorizer_tf, model_tf)# get predictions using the new pipeline.
predictions_tf = prediction_pipeline_tf.predict(X_test_text_annotated)# print the achieved accuracy.
accuracy_score(Y_test, predictions_tf)0.8858يحقق خط الأنابيب الجديد دقة تصل إلى 88.58%، وهو تحسن كبير بالمقارنة مع الدقة السابقة التي وصلت إلى 84.68%. يمكن الآن استخدام النموذج المحسن لإعادة النظر في مثال الاختبار الذي تم تصنيفه بشكل خاطئ بواسطة النموذج الأول:# get the review example that confused the previous algorithm mistake_example_annotated=X_test_text_annotated[4600]
print('\nReview:', mistake_example_annotated)# get the correct labels of this example.
print('\nCorrect Label:', class_names[Y_test[4600]])# get the prediction probabilities for this example.
print('\nPrediction Probabilities for neg, pos:',prediction_pipeline_tf.predict_proba([mistake_example_annotated]))Review: i_personally thought the movie was_pretty good very_good acting by tadanobu_ asano of ichi_the_killer fame i really can_t say much about the story but there_were parts that confused me a little_too much and overall i_thought the movie was just too lengthy other_than that however the movie contained superb_acting great fightings and a lot of the locations were beautifully_shot great effects and a lot of sword play another solid effort by tadanobu_asano in my_opinion well i really can_t say anymore about the movie but if_you re only outlook on asian_cinema is crouching_tiger hidden_ dragon or house of flying_daggers i_would suggest_you trying to rent_it but if_you re a die_hard asian_cinema fan i_would say this has to be in your_collection very_good japanese film Correct Label: pos Prediction Probabilities for neg, pos: [[0.32116538 0.67883462]]2023 - 1447
🎴 بطاقات تعليمية للمراجعة
عدد البطاقات: 5 بطاقة لهذه الصفحة
ماذا تمثل 'vectorizer_tf' في سياق بناء نموذج التنبؤ؟
الإجابة: تمثل 'vectorizer_tf' أداة التمثيل بالمتجهات التي تقوم بتحويل البيانات النصية إلى صيغة رقمية يمكن للنموذج تعلمها.
الشرح: قبل أن يتمكن نموذج التعلم الآلي من معالجة البيانات النصية، يجب تحويلها إلى تمثيل رقمي. 'vectorizer_tf' يقوم بهذه المهمة، مما يسمح للنموذج بفهم الأنماط والعلاقات في النصوص.
تلميح: فكر في الخطوة الأولى التي تحول الكلمات إلى أرقام لفهم الآلة.
ما هو اسم المصنف الذي تم تدريبه في هذا المثال؟
الإجابة: تم تدريب مصنف 'Naive Bayes Classifier' (بايز الساذج) في هذا المثال، وتم ترميزه بـ 'model_tf'.
الشرح: في سياق التعلم الآلي، 'model_tf' هو متغير يشير إلى نموذج التصنيف الذي تم إنشاؤه وتدريبه، وهو في هذه الحالة مصنف بايز الساذج.
تلميح: ابحث عن الكلمة التي تشير إلى نوع نموذج التصنيف الذي تم استخدامه.
ما الهدف من استخدام 'make_pipeline(vectorizer_tf, model_tf)'؟
الإجابة: يهدف استخدام 'make_pipeline' إلى تجميع خطوات معالجة البيانات والنمذجة في خط أنابيب واحد متكامل، مما يبسط عملية التنبؤ ويجعلها أكثر فعالية.
الشرح: خط الأنابيب (pipeline) يربط بين المعالجة المسبقة (vectorization) والنموذج (classification) في تسلسل واحد. هذا يعني أن البيانات تمر عبر كل خطوة تلقائيًا عند استخدام خط الأنابيب للتنبؤ، مما يقلل من احتمالية الأخطاء ويسهل التطبيق.
تلميح: فكر في فائدة دمج عدة خطوات في عملية واحدة متسلسلة.
ماذا تمثل 'X_train_v2' و 'Y_train' في سياق تدريب النموذج؟
الإجابة: تمثل 'X_train_v2' مجموعة بيانات التدريب النصية التي تم تمثيلها بالمتجهات (vectorized)، بينما تمثل 'Y_train' التصنيفات الصحيحة المقابلة لهذه البيانات.
الشرح: في التعلم الآلي، 'X' تمثل المدخلات أو الميزات التي يستخدمها النموذج للتعلم، و 'Y' تمثل المخرجات أو التصنيفات التي يحاول النموذج التنبؤ بها. 'v2' تشير إلى أنها نسخة ثانية أو معدلة من البيانات المتجهة.
تلميح: عادة ما تشير 'X' إلى الميزات و 'Y' إلى الهدف أو التصنيف.
كيف تم تقييم أداء النموذج الجديد مقارنة بالنموذج السابق؟
الإجابة: تم تقييم أداء النموذج الجديد بمقارنة دقته (accuracy) بالدقة السابقة، حيث حقق النموذج الجديد دقة 88.58%، وهو تحسن عن الدقة السابقة البالغة 84.68%.
الشرح: دقة النموذج (accuracy) هي مقياس شائع لتقييم أداء نماذج التصنيف. هي نسبة التنبؤات الصحيحة إلى إجمالي عدد التنبؤات. تحسن الدقة يشير إلى أن النموذج الجديد أصبح أفضل في تصنيف البيانات.
تلميح: ابحث عن مؤشر الأداء الذي تم استخدامه في المثال.