Step 2: Limits from the Evaluation چالش 2 از جلسهی 80، متوسط
تابع limits(ev) را بنویس که از دیکشنری ارزیابی، لیست جملههای محدودیت بسازد، به این ترتیب: ۱) اگر test کمتر از 20 است: Small test: only <test> samples, so the number may change a lot.؛ ۲) برای هر گروهی که درصدش بیش از 20 واحد از بهترین گروه کمتر است: Worse for <group>: <pct>% against <best>%.؛ ۳) اگر hallucinated بیشتر از صفر است: It made things up <n> time(s): always show the source.؛ ۴) اگر outside_range درست است: Not trusted outside the data it was trained on. خروجی:== Limits ==- Small test: only 15 samples, so the number may change a lot.- Worse for other class: 62% against 90%.- Not trusted outside the data it was trained on.
EVAL = {
"test": 15,
"groups": {"our group": 90, "other class": 62},
"hallucinated": 0,
"outside_range": True,
}
def limits(ev):
found = []
return found
print("== Limits ==")
for line in limits(EVAL):
print("-", line)
راهنما و جواب این چالش · برگشت به درس جلسهی 80: ارائه و گواهی نهایی · چالش بعدی: Step 3: The Ethics Checklist
بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال