تنظيم صفحاتك في مجموعات يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
لنفترض أنّ لديك نموذج انحدار لوجستي لرصد الرسائل الإلكترونية غير المرغوب فيها يتنبأ بقيمة تتراوح بين 0 و1، ما يمثّل احتمال أن تكون رسالتك الإلكترونية معيّنة غير مرغوب فيها. يشير التوقع 0.50 إلى احتمال بنسبة% 50 أن تكون الرسالة الإلكترونية غير مرغوب فيها، ويشير التوقع 0.75 إلى احتمال بنسبة% 75 أن تكون الرسالة الإلكترونية غير مرغوب فيها، وما إلى ذلك.
تريد نشر هذا النموذج في تطبيق بريد إلكتروني لفلترة الرسائل غير المرغوب فيها في مجلد بريد إلكتروني منفصل. ولكن لإجراء ذلك، عليك تحويل القيمة الرقمية التلقائية للنموذج (مثل 0.75) إلى إحدى الفئتَين التاليتَين: "محتوى غير مرغوب فيه" أو "محتوى غير غير مرغوب فيه".
لإجراء هذا التحويل، عليك اختيار حدّ احتمالي يُعرف باسم حدّ التصنيف. بعد ذلك، يتمّ إسناد الأمثلة التي تزيد احتماليتها عن الحدّ الأدنى إلى الفئة الموجبة، وهي الفئة التي تختبِرها (هنا، spam). ويتمّ إسناد الأمثلة التي تقلّ احتماليتها إلى الفئة السالبة، وهي الفئة البديلة (هنا، not spam).
انقر هنا للحصول على مزيد من التفاصيل حول الحدّ الأدنى للتصنيف
قد تتساءل: ماذا يحدث إذا كانت النتيجة المتوقّعة مساوية لمستوى التصنيف (على سبيل المثال، نتيجة 0.5 حيث يكون مستوى التصنيف هو 0.5 أيضًا)؟ يعتمد التعامل مع هذا الحالة على طريقة التنفيذ المحدّدة التي تم اختيارها لنموذج الترتيب. تتوقّع مكتبة Keras الفئة السلبية إذا كانت النتيجة والقيمة الحدّية متساويتين، ولكن قد تتعامل الأدوات/الأطر الأخرى مع هذا الموقف بشكل مختلف.
لنفترض أنّ النموذج يمنح رسالة إلكترونية واحدة درجة 0.99، ما يعني أنّه يتنبأ بأنّ احتمال أن تكون هذه الرسالة غير مرغوب فيها يبلغ 99%، ويمنح رسالة إلكترونية أخرى درجة 0.51، ما يعني أنّه يتنبأ بأنّ احتمال أن تكون هذه الرسالة غير مرغوب فيها يبلغ 51%. في حال ضبط الحدّ الأدنى للتصنيف على 0.5، سيصنّف النموذج كلتا الرسالتَين على أنّهما محتوى غير مرغوب فيه. في حال ضبط الحدّ الأدنى على 0.95، لن يتم تصنيف سوى الرسائل الإلكترونية التي تحصل على 0.99 كرسائل غير مرغوب فيها.
على الرغم من أنّ القيمة 0.5 قد تبدو كحدّ أدنى بديهي، إلا أنّه ليس من الجيد استخدامها إذا كانت تكلفة نوع واحد من التصنيفات الخاطئة أكبر من النوع الآخر، أو إذا كانت الفئات غير متوازنة. إذا كانت نسبة الرسائل غير المرغوب فيها تبلغ 0.01% فقط من الرسائل الإلكترونية، أو إذا كان وضع الرسائل الإلكترونية الصالحة في مجلد غير صحيح يؤدي إلى نتائج أسوأ من السماح بدخول الرسائل غير المرغوب فيها إلى البريد الوارد، يؤدي وضع علامة على أي محتوى يعتقد النموذج أنّ احتمال أن يكون غير مرغوب فيه يتجاوز% 50 باعتباره غير مرغوب فيه إلى نتائج غير مرغوب فيها.
مصفوفة نجاح التوقّعات
لا تشير نتيجة الاحتمالية إلى الواقع أو الحقيقة الأساسية. هناك أربع نتائج محتملة لكل ناتج من أحد المصنّفات الثنائية. في مثال مصنّف الرسائل غير المرغوب فيها، إذا وضّحت الحقائق الأساسية كأعمدة وتوقّعات النموذج كصفوف، سيكون الجدول التالي المُسمى مصفوفة الالتباس هو النتيجة:
النتيجة الإيجابية الفعلية
القيمة السلبية الفعلية
نتيجة إيجابية متوقّعة
نتيجة إيجابية صحيحة (TP): رسالة إلكترونية غير مرغوب فيها تم تصنيفها بشكل صحيح على أنّها رسالة إلكترونية غير مرغوب فيها. هذه هي الرسائل غير المرغوب فيها التي يتم تلقائيًا إرسالها إلى مجلد الرسائل غير المرغوب فيها.
نتيجة إيجابية خاطئة (FP): رسالة إلكترونية ليست غير مرغوب فيها تم تصنيفها خطأً على أنّها غير مرغوب فيها. هذه هي الرسائل الإلكترونية الصالحة التي تنتهي في مجلد الرسائل غير المرغوب فيها.
القيمة السلبية المتوقّعة
نتيجة سالبة خاطئة (FN): رسالة إلكترونية غير مرغوب فيها تم تصنيفها بشكل خاطئ على أنّها ليست رسالة غير مرغوب فيها. هذه هي رسائل البريد الإلكتروني غير المرغوب فيها التي لا يتم اكتشافها من خلال فلتر الرسائل غير المرغوب فيها وتصل إلى البريد الوارد.
سلبي صحيح (TN): رسالة إلكترونية ليست غير مرغوب فيها تم تصنيفها بشكل صحيح على أنّها ليست غير مرغوب فيها. هذه هي الرسائل الإلكترونية المشروعة التي يتم إرسالها مباشرةً إلى البريد الوارد.
يُرجى العلم أنّ المجموع في كل صف يعرض جميع القيم الإيجابية المتوقّعة (TP + FP) وجميع القيم السلبية المتوقّعة (FN + TN)، بغض النظر عن مدى صلاحيتها. في المقابل، يعرض المجموع في كل عمود كل القيم الإيجابية الحقيقية (TP + FN) وكل القيم السلبية الحقيقية (FP + TN) بغض النظر عن تصنيف النموذج.
عندما لا يكون إجمالي القيم الموجبة الفعلية قريبًا من إجمالي القيم السلبية الفعلية، تكون مجموعة البيانات غير متوازنة. قد يكون مثالاً على مجموعة البيانات غير المتوازنة مجموعة من آلاف صور السحب، حيث يظهر نوع السحب النادر الذي يهمّك، مثل السحب المتصاعدة، بضع مرات فقط.
تأثير الحدّ الأدنى على القيم الموجبة والسالبة الصحيحة والخاطئة
تؤدي الحدود الدنيا المختلفة عادةً إلى أعداد مختلفة من حالات الموجب الخاطئ والموجب الصحيح والسالب الخاطئ والسالب الصحيح. يوضّح الفيديو التالي سبب حدوث ذلك.
جرِّب تغيير الحدّ الأدنى بنفسك.
تتضمّن هذه الأداة المصغّرة ثلاث مجموعات بيانات للألعاب:
مفصَّلة، حيث يتم بشكل عام التمييز جيدًا بين الأمثلة الإيجابية والسلبية، مع حصول معظم الأمثلة الإيجابية على نتائج أعلى من الأمثلة السلبية
غير مفصولة، حيث تحقّق العديد من الأمثلة الإيجابية نتائج أقل من الأمثلة السلبية، وتحقّق العديد من الأمثلة السلبية نتائج أعلى من الأمثلة الإيجابية.
غير متوازنة، إذ تحتوي على عدد قليل من الأمثلة على الفئة الموجبة
التحقّق من فهمك
1. لنفترض أنّ لدينا نموذجًا لتصنيف المواقع الإلكترونية للتصيّد الاحتيالي أو البرامج الضارة، حيث: تندرج المواقع الإلكترونية للتصيّد الاحتيالي والبرامج الضارة في الفئة التي تحمل التصنيف 1 (صحيح) تندرج المواقع الإلكترونية غير الضارة في الفئة التي تحمل التصنيف 0 (خطأ). يصنف هذا النموذج موقعًا إلكترونيًا مشروعًا عن طريق الخطأ على أنّه برنامج ضار. ماذا يُسمى هذا الإجراء؟
نتيجة موجبة خاطئة
تم تصنيف مثال سلبي (موقع إلكتروني مشروع) عن طريق الخطأ على أنّه مثال موجب (موقع إلكتروني يتضمّن برامج ضارة).
موجب صحيح
الحالة الموجبة الصائبة هي موقع إلكتروني لبرامج ضارة تم تصنيفه بشكلٍ صحيح على أنّه موقع إلكتروني لبرامج ضارة.
نتيجة سلبية خاطئة
الحالة السلبية الخاطئة هي موقع إلكتروني يتضمّن برامج ضارة تم تصنيفه عن طريق الخطأ على أنّه موقع إلكتروني مشروع.
نتيجة سالبة صحيحة
الحالة السلبية الصحيحة هي موقع إلكتروني موثوق به تم تصنيفه بشكل صحيح على أنّه موقع إلكتروني موثوق به.
2. بشكل عام، ماذا يحدث لعدد النتائج الإيجابية الخاطئة عندما يزداد عتبة التصنيف؟ ماذا عن الحالات الموجبة الصحيحة؟ جرِّب استخدام شريط التمرير أعلاه.
ينخفض كلّ من النتائج الموجبة الصائبة والنتائج الموجبة الخاطئة.
مع زيادة الحدّ الأدنى، من المرجّح أن يتوقّع النموذج عددًا أقل من القيم الموجبة بشكل عام، سواء كانت صحيحة أو خاطئة. لن يصنف نظام تصنيف الرسائل غير المرغوب فيها الذي يستخدم حدًا أدنى يبلغ .9999 رسالة إلكترونية على أنّها غير مرغوب فيها إلا إذا اعتبر أنّ احتمال التصنيف يبلغ 99.99% على الأقل، ما يعني أنّه من غير المرجّح أن يخطئ في تصنيف رسالة إلكترونية مشروعة، ولكن من المرجّح أيضًا أن يفوت عليه رسالة إلكترونية غير مرغوب فيها فعلاً.
تزداد كلّ من النتائج الموجبة الصائبة والنتائج الموجبة الخاطئة.
باستخدام شريط التمرير أعلاه، جرِّب ضبط الحدّ الأدنى على 0.1، ثم سحقه إلى 0.9. ماذا يحدث لعدد الحالات الموجبة الخاطئة والحالات الموجبة الصحيحة؟
تزداد الحالات الموجبة الصحيحة. انخفاض عدد النتائج الموجبة الخاطئة
باستخدام شريط التمرير أعلاه، حاوِل ضبط الحدّ الأدنى على 0.1، ثم اسحب شريط التمرير إلى 0.9. ماذا يحدث لعدد الحالات الموجبة الخاطئة والحالات الموجبة الصحيحة؟
3- بشكل عام، ماذا يحدث لعدد النتائج السالبة الخاطئة عندما يزداد عتبة التصنيف؟ ماذا عن الحالات السالبة الصحيحة؟ جرِّب استخدام شريط التمرير أعلاه.
تزداد كلّ من النتائج السالبة الصائبة والنتائج السالبة الخاطئة.
مع زيادة الحدّ الأدنى، من المرجّح أن يتوقّع النموذج المزيد من النتائج السالبة بشكل عام، سواء كانت صحيحة أو خاطئة. عند بلوغ حدّ أقصى مرتفع جدًا، سيتم تصنيف جميع الرسائل الإلكترونية تقريبًا، سواء كانت رسائل غير مرغوب فيها أو غير ذلك، على أنّها ليست رسائل غير مرغوب فيها.
ينخفض كلا النوعَين من النتائج السالبة، أي النتائج السالبة الصائبة والنتائج السالبة الخاطئة.
باستخدام شريط التمرير أعلاه، حاوِل ضبط الحدّ الأدنى على 0.1، ثم اسحب شريط التمرير إلى 0.9. ماذا يحدث لعدد الحالات السالبة الخاطئة والحالات السالبة الصحيحة؟
تزداد الحالات السالبة الصحيحة. انخفاض الحالات السالبة الخاطئة
باستخدام شريط التمرير أعلاه، حاوِل ضبط الحدّ الأدنى على 0.1، ثم اسحب شريط التمرير إلى 0.9. ماذا يحدث لعدد الحالات السالبة الخاطئة والحالات السالبة الصحيحة؟
تاريخ التعديل الأخير: 2025-05-22 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-05-22 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["Let's say you have a logistic regression model for spam-email detection that\npredicts a value between 0 and 1, representing the probability that a given\nemail is spam. A prediction of 0.50 signifies a 50% likelihood that the email is\nspam, a prediction of 0.75 signifies a 75% likelihood that the email is spam,\nand so on.\n\nYou'd like to deploy this model in an email application to filter spam into\na separate mail folder. But to do so, you need to convert the model's raw\nnumerical output (e.g., `0.75`) into one of two categories: \"spam\" or \"not\nspam.\"\n\nTo make this conversion, you choose a threshold probability, called a\n[**classification threshold**](/machine-learning/glossary#classification-threshold).\nExamples with a probability above the threshold value are then assigned\nto the [**positive class**](/machine-learning/glossary#positive_class),\nthe class you are testing for (here, `spam`). Examples with a lower\nprobability are assigned to the [**negative class**](/machine-learning/glossary#negative_class),\nthe alternative class (here, `not spam`). \n\n**Click here for more details on the classification threshold**\n\nYou may be wondering: what happens if the predicted score is equal to\nthe classification threshold (for instance, a score of 0.5 where\nthe classification threshold is also 0.5)? Handling for this case\ndepends on the particular implementation chosen for the classification\nmodel. The [Keras](https://keras.io/)\nlibrary predicts the negative class if the score and threshold\nare equal, but other tools/frameworks may handle this case\ndifferently.\n\nSuppose the model scores one email as 0.99, predicting\nthat email has a 99% chance of being spam, and another email as\n0.51, predicting it has a 51% chance of being spam. If you set the\nclassification threshold to 0.5, the model will classify both emails as\nspam. If you set the threshold to 0.95, only the email scoring 0.99 will\nbe classified as spam.\n\nWhile 0.5 might seem like an intuitive threshold, it's not a good idea if the\ncost of one type of wrong classification is greater than the other, or if the\nclasses are imbalanced. If only 0.01% of emails are spam, or if misfiling\nlegitimate emails is worse than letting spam into the inbox,\nlabeling anything the model considers at least 50% likely to be spam\nas spam produces undesirable results.\n\nConfusion matrix\n\nThe probability score is not reality, or\n[**ground truth**](/machine-learning/glossary#ground_truth).\nThere are four possible outcomes for each output from a binary classifier.\nFor the spam classifier example, if you lay out the ground truth as columns\nand the model's prediction as rows, the following table, called a\n[**confusion matrix**](/machine-learning/glossary#confusion_matrix), is the\nresult:\n\n| | Actual positive | Actual negative |\n| Predicted positive | **True positive (TP)**: A spam email correctly classified as a spam email. These are the spam messages automatically sent to the spam folder. | **False positive (FP)**: A not-spam email misclassified as spam. These are the legitimate emails that wind up in the spam folder. |\n| Predicted negative | **False negative (FN)**: A spam email misclassified as not-spam. These are spam emails that aren't caught by the spam filter and make their way into the inbox. | **True negative (TN)**: A not-spam email correctly classified as not-spam. These are the legitimate emails that are sent directly to the inbox. |\n|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|\n\nNotice that the total in each row gives all predicted positives (TP + FP) and\nall predicted negatives (FN + TN), regardless of validity. The total in each\ncolumn, meanwhile, gives all real positives (TP + FN) and all real negatives\n(FP + TN) regardless of model classification.\n\nWhen the total of actual positives is not close to the total of actual\nnegatives, the dataset is\n[**imbalanced**](/machine-learning/glossary#class_imbalanced_data_set). An instance\nof an imbalanced dataset might be a set of thousands of photos of clouds, where\nthe rare cloud type you are interested in, say, volutus clouds, only appears\na few times.\n\nEffect of threshold on true and false positives and negatives\n\nDifferent thresholds usually result in different numbers of true and false\npositives and true and false negatives. The following video explains why this is\nthe case. \n\nTry changing the threshold yourself.\n\nThis widget includes three toy datasets:\n\n- **Separated**, where positive examples and negative examples are generally well differentiated, with most positive examples having higher scores than negative examples.\n- **Unseparated**, where many positive examples have lower scores than negative examples, and many negative examples have higher scores than positive examples.\n- **Imbalanced**, containing only a few examples of the positive class.\n\nCheck your understanding \n1. Imagine a phishing or malware classification model where phishing and malware websites are in the class labeled **1** (true) and harmless websites are in the class labeled **0** (false). This model mistakenly classifies a legitimate website as malware. What is this called? \nA false positive \nA negative example (legitimate site) has been wrongly classified as a positive example (malware site). \nA true positive \nA true positive would be a malware site correctly classified as malware. \nA false negative \nA false negative would be a malware site incorrectly classified as a legitimate site. \nA true negative \nA true negative would be a legitimate site correctly classified as a legitimate site. \n2. In general, what happens to the number of false positives when the classification threshold increases? What about true positives? Experiment with the slider above. \nBoth true and false positives decrease. \nAs the threshold increases, the model will likely predict fewer positives overall, both true and false. A spam classifier with a threshold of .9999 will only label an email as spam if it considers the classification to be at least 99.99% likely, which means it is highly unlikely to mislabel a legitimate email, but also likely to miss actual spam email. \nBoth true and false positives increase. \nUsing the slider above, try setting the threshold to 0.1, then dragging it to 0.9. What happens to the number of false positives and true positives? \nTrue positives increase. False positives decrease. \nUsing the slider above, try setting the threshold to 0.1, then dragging it to 0.9. What happens to the number of false positives and true positives? \n3. In general, what happens to the number of false negatives when the classification threshold increases? What about true negatives? Experiment with the slider above. \nBoth true and false negatives increase. \nAs the threshold increases, the model will likely predict more negatives overall, both true and false. At a very high threshold, almost all emails, both spam and not-spam, will be classified as not-spam. \nBoth true and false negatives decrease. \nUsing the slider above, try setting the threshold to 0.1, then dragging it to 0.9. What happens to the number of false negatives and true negatives? \nTrue negatives increase. False negatives decrease. \nUsing the slider above, try setting the threshold to 0.1, then dragging it to 0.9. What happens to the number of false negatives and true negatives?\n| **Key terms:**\n|\n| - [Binary classification](/machine-learning/glossary#binary-classification)\n| - [Class-imbalanced dataset](/machine-learning/glossary#class_imbalanced_data_set)\n| - [Classification threshold](/machine-learning/glossary#classification-threshold)\n| - [Confusion matrix](/machine-learning/glossary#confusion_matrix)\n| - [Ground truth](/machine-learning/glossary#ground_truth)\n| - [Negative class](/machine-learning/glossary#negative_class)\n- [Positive class](/machine-learning/glossary#positive_class) \n[Help Center](https://support.google.com/machinelearningeducation)"]]