الماشين ليرنينج · AI216

الـ Multiclass Classification: One-versus-One و One-versus-Rest

الماشين ليرنينج شروحات ومراجعات

الـ multiclass classification بيحط الـ instance في واحد من أكتر من فئتين، وبنقدر نستخدم binary classifiers بأسلوب one-versus-rest (OvR/OvA) أو one-versus-one (OvO).

فيه خوارزميات (Random Forest وnaive Bayes) بتتعامل مع classes كتير مباشرة. وغيرها زي SGD وSVM binary بس. عشان تصنف أرقام من 0 لـ 9 بـ binary classifier عندك استراتيجيتين.

One-versus-the-rest (OvR أو OvA): تدرّب 10 binary classifiers، واحد لكل رقم (الرقم ده ضد الباقي)، وتشغّلهم كلهم على الصورة الجديدة وتختار الـ class اللي الـ classifier بتاعه عنده أعلى decision score. One-versus-one (OvO): تدرّب classifier لكل زوج من الـ classes. لو N classes محتاج N × (N - 1) / 2 classifiers يعني 45 لـ 10 أرقام. ميزته إن كل classifier محتاج جزء من الـ training set بس (الفئتين بتوعه) وده بيفيد الخوارزميات اللي بتتأثر بحجم التدريب زي SVM.

Scikit-Learn بيختار لوحده: OvO للـ SVM وOvR لمعظم الباقي.

أهم النقاط

  • OvR: N classifiers وبنختار أعلى score.
  • OvO: N(N-1)/2 classifier، واحد لكل زوج، يعني 45 لـ 10 classes.
  • الـ SVM بيفضل OvO لأنه بيتأثر بحجم الـ training set.
  • SGD وSVM binary بس، وRandom Forest بيتعامل multiclass مباشرة.

مثال محلول

لـ 3 classes (قطة وكلب وعصفور) الـ OvO بيدرب قطة-ضد-كلب وقطة-ضد-عصفور وكلب-ضد-عصفور: 3 × 2 / 2 = 3 classifiers، والـ class اللي بيكسب أكتر مواجهات هو التوقع.

أسئلة شائعة

الـ OvO محتاج كام classifier لـ 10 classes؟

45 لأن 10 × 9 / 2 = 45.

أنهي خوارزميات binary بس؟

الـ SGD classifiers والـ Support Vector Machine classifiers.

أسئلة تدريب على الموضوع ده

جرّبها بنفسك، وبعدين افتح التطبيق وشوف الإجابة والشرح.

  1. There are various strategies that you can use to perform multiclass classification with multiple binary classifiers.
    • A. true
    • B. false
  2. What is the difference between a binary classification algorithm and a multiclass classification algorithm
    • A. A binary classification algorithm can only predict two classes, while a multiclass classification algorithm can predict three or more classes.
    • B. A binary classification algorithm is more accurate than a multiclass classification algorithm.
    • C. A binary classification algorithm is more computationally expensive than a multiclass classification algorithm.
    • D. A binary classification algorithm is not as flexible as a multiclass classification algorithm.
  3. In The One-versus-one (OvO) Strategy, you need .............classifiers for MNIST dataset
    • A. 45
    • B. Nx (N-1)/2
    • C. both of them
    • D. none of them
  4. A single binary classifier is more computationally expensive than a multiclass strategy built from several binary classifiers (OvR or OvO).
    • A. false
    • B. true
  5. In The One-versus-one (OvO) Strategy, you need........... classifiers for classifiers for MNIST dataset.
    • A. 45
    • B. N × (N–1)/2
    • C. both of them
    • D. none of them