Generalization, Data Quality, and Model Evaluation
هوش مصنوعی برای همه: هوش مصنوعی چطور باهوش شد؟
- Training, validation, and test examples as distinct parts of model development.
- Underfitting and overfitting through simple curves and fruit-classification examples.
- Data leakage and why reusing test answers can produce misleading results.
- Correct and incorrect predictions by category; accuracy, precision, and recall using small counts.
- Shortcut learning, noisy labels, and unrepresentative sampling in object datasets.
- Distribution shift, illustrated by studio fruit photographs versus dimly lit images.
- Why a prediction score is not automatically a calibrated probability of correctness.
جداسازی نقشهای داده
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><rect class="tm-accent" x="40" y="55" width="220" height="105" rx="14"/><text class="tm-text" x="150" y="95" text-anchor="middle" font-size="20">training</text><text class="tm-muted" x="150" y="127" text-anchor="middle" font-size="16" direction="rtl">یادگیری از عکس و برچسب</text><rect class="tm-accent" x="290" y="55" width="220" height="105" rx="14"/><text class="tm-text" x="400" y="95" text-anchor="middle" font-size="20">validation</text><text class="tm-muted" x="400" y="127" text-anchor="middle" font-size="16" direction="rtl">انتخاب نسخه</text><rect class="tm-accent" x="540" y="55" width="220" height="105" rx="14"/><text class="tm-text" x="650" y="95" text-anchor="middle" font-size="20">test</text><text class="tm-muted" x="650" y="127" text-anchor="middle" font-size="16" direction="rtl">ارزیابی نهایی</text><rect class="tm-soft" x="75" y="205" width="145" height="75" rx="12"/><text class="tm-text" x="147" y="250" text-anchor="middle" font-size="18" direction="rtl">عکس سیب</text><path class="tm-line" d="M147 205 L147 165"/><rect class="tm-soft" x="327" y="205" width="145" height="75" rx="12"/><text class="tm-text" x="399" y="250" text-anchor="middle" font-size="18" direction="rtl">دو نسخه</text><path class="tm-line" d="M399 205 L399 165"/><rect class="tm-soft" x="577" y="205" width="145" height="75" rx="12"/><text class="tm-text" x="649" y="250" text-anchor="middle" font-size="18" direction="rtl">عکس کنارگذاشتهشده</text><path class="tm-line" d="M649 205 L649 165"/><text class="tm-muted" x="400" y="340" text-anchor="middle" font-size="18" direction="rtl">هر عکس فقط در نقش خودش</text><rect class="tm-gold tm-enter" x="260" y="375" width="280" height="52" rx="12"/><text class="tm-text-gold" x="400" y="408" text-anchor="middle" font-size="18" direction="rtl">data leakage: test وارد انتخاب شد</text></svg>
```
خطای مدل در دو مجموعه
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><defs><marker id="arrow" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto"><path d="M0,0 L0,6 L7,3 z" class="tm-arrow"/></marker></defs><path d="M100 340 L700 340" class="tm-line"/><path d="M100 340 L100 75" class="tm-line"/><text x="400" y="390" class="tm-text" font-size="16" text-anchor="middle" direction="rtl">پیچیدگی مدل</text><text x="38" y="205" class="tm-text" font-size="16" text-anchor="middle" transform="rotate(-90 38 205)" direction="rtl">خطا</text><text x="105" y="365" class="tm-muted" font-size="13" direction="rtl">ساده</text><text x="675" y="365" class="tm-muted" font-size="13" direction="rtl">پیچیده</text><path d="M125 130 C270 190 430 270 675 300" fill="none" class="tm-line-accent" stroke-width="4"/><path d="M125 145 C235 185 300 275 390 295 C500 300 560 250 675 140" fill="none" class="tm-line" stroke-width="4"/><text x="185" y="135" class="tm-text-accent" font-size="15" direction="rtl">خطای training</text><text x="470" y="190" class="tm-text" font-size="15" direction="rtl">خطای validation</text><rect x="125" y="90" width="130" height="58" rx="10" class="tm-soft"/><text x="190" y="115" class="tm-text" font-size="14" text-anchor="middle">underfitting</text><text x="190" y="135" class="tm-muted" font-size="12" text-anchor="middle" direction="rtl">هر دو خطا زیاد</text><rect x="315" y="225" width="150" height="58" rx="10" class="tm-green"/><text x="390" y="249" class="tm-text" font-size="14" text-anchor="middle" direction="rtl">یادگیری بهتر</text><text x="390" y="269" class="tm-muted" font-size="12" text-anchor="middle" direction="rtl">هر دو خطا کم</text><rect x="560" y="100" width="150" height="60" rx="10" class="tm-gold"/><text x="635" y="124" class="tm-text" font-size="14" text-anchor="middle">overfitting</text><text x="635" y="145" class="tm-muted" font-size="12" text-anchor="middle" direction="rtl">validation بالا میرود</text><text x="400" y="425" class="tm-text" font-size="13" text-anchor="middle" direction="rtl">انتخاب با validation | سنجش نهایی با test</text></svg>
```
محاسبهٔ معیارهای طبقهبندی
جدول دهعکسی: چهار سیب واقعی با پیشبینی سیب؛ دو پرتقال واقعی با پیشبینی سیب؛ یک سیب واقعی با پیشبینی پرتقال؛ سه پرتقال واقعی با پیشبینی پرتقال. سیب دستهٔ مثبت است.
**شمارش پاسخها**
\[ TP=4,\quad FP=2,\quad FN=1,\quad TN=3 \]
مثبت: سیب
**Accuracy**
\[ \frac{TP+TN}{10}=\frac{4+3}{10}=\frac{7}{10}=70\% \]
۷ پاسخ درست از ۱۰
**Precision برای سیب**
\[ \frac{TP}{TP+FP}=\frac{4}{4+2}=\frac{4}{6}\approx 67\% \]
از اعلامهای سیب، چندتا واقعاً سیباند؟
**Recall برای سیب**
\[ \frac{TP}{TP+FN}=\frac{4}{4+1}=\frac{4}{5}=80\% \]
از سیبهای واقعی، چندتا پیدا شدهاند؟
**کاربرد معیارها**
\[ \text{Precision: اعلامهای سیب}\qquad \text{Recall: سیبهای ازدسترفته} \]
هر معیار به پرسشی متفاوت پاسخ میدهد.
**محدودیت نمونه**
\[ n=10 \]
برای تمرین مناسب؛ برای نتیجهگیری محکم بسیار کوچک
کیفیت و تنوع داده
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><rect class="tm-surface" x="30" y="55" width="220" height="145" rx="14"/><text class="tm-text" x="140" y="85" font-size="18" text-anchor="middle" direction="rtl">سیب روی پارچه آبی</text><circle class="tm-green" cx="140" cy="140" r="30"/><rect class="tm-soft" x="550" y="55" width="220" height="145" rx="14"/><text class="tm-text" x="660" y="85" font-size="18" text-anchor="middle" direction="rtl">پرتقال روی پارچه سفید</text><circle class="tm-gold" cx="660" cy="140" r="30"/><path class="tm-line" d="M250 130 H550"/><text class="tm-muted" x="400" y="115" font-size="16" text-anchor="middle" direction="rtl">رنگ پارچه ← سرنخ</text><rect class="tm-accent" x="290" y="230" width="220" height="62" rx="12"/><text class="tm-text" x="400" y="268" font-size="18" text-anchor="middle">shortcut learning</text><text class="tm-muted" x="400" y="330" font-size="16" text-anchor="middle" direction="rtl">وابستگی به پسزمینه؟</text><rect class="tm-accent" x="290" y="355" width="220" height="62" rx="12"/><text class="tm-text" x="400" y="393" font-size="18" text-anchor="middle" direction="rtl">همان سیب، پارچه سفید</text><rect class="tm-surface" x="30" y="215" width="220" height="85" rx="12"/><text class="tm-text" x="140" y="250" font-size="17" text-anchor="middle" direction="rtl">برچسب اشتباه</text><text class="tm-text" x="140" y="278" font-size="16" text-anchor="middle" direction="rtl">پرتقال ← سیب</text><rect class="tm-soft" x="550" y="215" width="220" height="85" rx="12"/><text class="tm-text" x="660" y="250" font-size="17" text-anchor="middle" direction="rtl">عکسهای بیشتر</text><text class="tm-muted" x="660" y="278" font-size="15" text-anchor="middle" direction="rtl">همان خطا، کمک نمیکند</text><rect class="tm-surface" x="30" y="325" width="220" height="90" rx="12"/><text class="tm-text" x="140" y="360" font-size="16" text-anchor="middle" direction="rtl">نمونههای محدود</text><text class="tm-muted" x="140" y="388" font-size="14" text-anchor="middle" direction="rtl">سالم، کامل، استودیو</text><rect class="tm-gold" x="550" y="325" width="220" height="90" rx="12"/><text class="tm-text" x="660" y="360" font-size="16" text-anchor="middle" direction="rtl">شرایط استفاده</text><text class="tm-muted" x="660" y="388" font-size="14" text-anchor="middle" direction="rtl">نیمهپوشیده، کمنور</text><path class="tm-line-accent tm-enter" d="M250 370 H550" marker-end="url(#arrow)"/><text class="tm-text-accent" x="400" y="435" font-size="16" text-anchor="middle" direction="rtl">distribution shift: سنجش جداگانه با عکس کمنور واقعی</text></svg>
```
امتیاز بالا، نه تضمین
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><rect class="tm-surface" x="40" y="42" width="210" height="125" rx="14"/><text class="tm-text" x="145" y="78" font-size="18" text-anchor="middle" direction="rtl">عکس استودیویی</text><text class="tm-text2" x="145" y="112" font-size="16" text-anchor="middle" direction="rtl">پیشبینی: سیب</text><text class="tm-text-accent" x="145" y="145" font-size="17" text-anchor="middle" direction="rtl">امتیاز \(90\%\)</text><rect class="tm-soft" x="310" y="42" width="210" height="125" rx="14"/><text class="tm-text" x="415" y="78" font-size="18" text-anchor="middle" direction="rtl">Calibration مناسب</text><text class="tm-text-accent" x="415" y="115" font-size="19" text-anchor="middle" direction="rtl">در این شرایط</text><line class="tm-line" x1="250" y1="105" x2="308" y2="105"/><rect class="tm-taupe" x="550" y="42" width="210" height="125" rx="14"/><text class="tm-text" x="655" y="78" font-size="18" text-anchor="middle" direction="rtl">عکس کمنور</text><text class="tm-muted" x="655" y="115" font-size="16" text-anchor="middle" direction="rtl">همان امتیاز، احتمال خطا</text><line class="tm-line" x1="520" y1="105" x2="548" y2="105"/><text class="tm-text" x="400" y="220" font-size="19" text-anchor="middle" direction="rtl">تغییر نور: distribution shift</text><rect class="tm-surface" x="105" y="252" width="270" height="132" rx="14"/><text class="tm-text" x="240" y="286" font-size="17" text-anchor="middle" direction="rtl">\(100\) پیشبینی نزدیک \(90\%\)</text><text class="tm-muted" x="240" y="321" font-size="16" text-anchor="middle" direction="rtl">بررسی جوابهای واقعی</text><text class="tm-text2" x="240" y="354" font-size="16" text-anchor="middle" direction="rtl">گروه و شرایط مشخص</text><rect class="tm-surface" x="425" y="252" width="270" height="132" rx="14"/><text class="tm-text" x="560" y="286" font-size="17" text-anchor="middle" direction="rtl">نتیجهی درستها</text><text class="tm-muted" x="560" y="321" font-size="16" text-anchor="middle" direction="rtl">نه تضمین همیشگی</text><text class="tm-muted" x="560" y="354" font-size="16" text-anchor="middle" direction="rtl">ارزیابی در شرایط تازه</text><line class="tm-line" x1="375" y1="318" x2="423" y2="318"/></svg>
```
Back to course