بتل کد Battle Codeدارد باز می‌شود…

جواب «All Tracks: My Project Plan» چالش 2 از جلسه‌ی 77

سؤال

نقشه‌ی پروژه‌ی خودت را در PLAN بنویس (مسیر A، B یا C). تابع check_plan که آماده است، اگر چیزی کم باشد با یک پیام روشن خطا می‌دهد: هدف و داده و روش خالی نباشند، معیار دست‌کم یک رقم داشته باشد، و دست‌کم دو خطر بنویسی. وقتی بدون خطا اجرا شد و کارت نقشه‌ات چاپ شد، این قدم تمام است. (هر نقشه‌ی درستی قبول است؛ لازم نیست مثل نمونه باشد.)

راهنما

هر خانه‌ی خالی را با یک جمله‌ی کوتاه درباره‌ی پروژه‌ی خودت پر کن. معیار مثل: at least 80% on 15 test images. خطرها یک لیست دوتایی از جمله‌ها.

یک جواب درست

PLAN = {
    "track": "B",      # "A" study bot, "B" image classifier, "C" school data
    "goal": "Tell hand-drawn circles, crosses and lines apart for a class drawing game.",
    "data": "60 drawings on a 5x5 grid made by our group, 20 of each kind, no faces.",
    "method": "Average image of each class (nearest centroid), then k-NN with k=3.",
    "metric": "At least 80% right on 15 test drawings I do not look at while building.",
    "risks": ["My own drawings may differ from others': ask 3 classmates to draw the test set.",
              "One class may have fewer drawings: count them and keep the classes balanced."],
}


def check_plan(plan):
    if plan["track"] not in ("A", "B", "C"):
        raise ValueError('track must be "A", "B" or "C"')
    for key in ("goal", "data", "method"):
        if not plan[key].strip():
            raise ValueError(key + " is empty")
    if not any(ch.isdigit() for ch in plan["metric"]):
        raise ValueError("the metric needs a number, for example: at least 80% on 15 test images")
    if len(plan["risks"]) < 2:
        raise ValueError("write at least two risks")


check_plan(PLAN)
print("PLAN OK - track", PLAN["track"])
for key in ("goal", "data", "method", "metric"):
    print(f"{key:>7}: {PLAN[key]}")
for risk in PLAN["risks"]:
    print("   risk:", risk)

اول خودت امتحان کن؛ جواب‌های دیگر هم قبول است. برگرد و خودت حلش کن