נתונים קטגוריים: תרגולים שונים של תכונות
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Playground היא אפליקציה אינטראקטיבית שמאפשרת לשנות היבטים שונים של אימון ובדיקה של מודל למידת מכונה.
ב-Playground אפשר לבחור תכונות ולשנות היפר-פרמטרים,
ולגלות איך הבחירות שלכם משפיעות על המודל.
הדף הזה מכיל שני תרגילים ב-Playground.
תרגיל 1: הצלבת תכונות בסיסיות
בתרגיל הזה, נתמקד בחלקים הבאים בממשק המשתמש של Playground:
- מתחת לתכונות, שימו לב לשלוש תכונות אפשריות של המודל:
- מתחת לפלט יופיע ריבוע שמכיל כתום
והנקודות הכחולות. נניח שאתם מסתכלים על יער מרובע, שבו
נקודות כתומות מציינות את המיקום של עצים חולים ונקודות כחולות מציינות
של עצים בריאים.
- בין FEATURES ל-OUTPUT, אם תסתכלו מקרוב, תראו
קווים חלשים מקווקווים שמחברים כל מאפיין לפלט.
הרוחב של כל קו מקווקו מסמל את המשקל שמשויך כרגע
לגבי כל תכונה. השורות האלה חלשים מאוד מפני שמשקל ההתחלה
עבור כל מאפיין, המערכת מאתחלת את הערך 0. ככל שהמשקל יגדל או יקטן, כך יתחזק או יתחלש העובי של הקווים האלה.
משימה 1: בודקים את Playground באופן הבא:
- לוחצים על הקו הדק שמחבר את המאפיין x1 לפלט.
יופיע חלון קופץ.
- בחלון הקופץ, מזינים את המשקל
1.0
.
- מקישים על Enter.
חשוב לשים לב לפרטים הבאים:
- הקו המקווקו של x1 נעשה עבה יותר ככל שהמשקל גדל
מ-0 ל-1.0.
- יופיע רקע כתום וכחול.
- הרקע הכתום הוא הניחושים של המודל בנוגע למיקום העצים החולים
הן.
- הרקע הכחול הוא הניחוש של המודל לגבי המיקום של העצים הבריאים
הן.
המודל עושה עבודה גרועה, כמחצית מהניחושים של המודל
שגוי.
- מאחר שהמשקל הוא 1.0 עבור x1 ו-0 עבור המאפיינים האחרים, המודל תואם בדיוק לערכים של x1.
משימה 2: שנו את המשקולות של כל אחת משלושת הישויות האלה, כך
(צבעי הרקע) יחזה בהצלחה
עצים. הפתרון מופיע ממש מתחת ל-Playground.
הפתרון למטלה 2
- w1 = 0
- w2 = 0
- x1 x2 = כל ערך חיובי
בשביל הכיף, מה יקרה אם מזינים ערך שלילי לתכונה
צלב?
תרגול 2: שילוב תכונות מתקדם יותר
בתרגיל השני, בדקו את סידור הנקודות הכתומות (עצים חולים)
ונקודות כחולות (עצים בריאים) במודל הפלט, תוך התייחסות לדברים הבאים:
- הנקודות יוצרות דפוסים כדוריים.
- הסדר של הנקודות רועש. לדוגמה, שימו לב לכחול
נקודות בכדור החיצוני של הנקודות הכתומות. כתוצאה מכך, גם מודל מצוין לא צפוי לחזות בצורה מדויקת כל נקודה.
משימה 1: מבצעים את הפעולות הבאות כדי לחקור את ממשק המשתמש של Playground:
- ללחוץ על הלחצן 'הפעלה/השהיה', שהוא משולש לבן בתוך משולש שחור
מעגל. Playground יתחיל לאמן את המודל. תוכלו לראות את המספר של Epochs עולה.
- אחרי שהמערכת תאמן במשך 300 מחזורים לפחות, לוחצים על אותו לחצן הפעלה/השהיה כדי להשהות את האימון.
- תראו את המודל. האם המודל מספק תחזיות טובות? במילים אחרות, האם הנקודות הכחולות מוקפות בדרך כלל ברקע כחול, והנקודות הכתומים מוקפות בדרך כלל ברקע כתום?
- בודקים את הערך של 'אובדן בבדיקה' שמופיע מתחת ל'פלט'. האם הערך קרוב יותר ל-1.0 (אובדן גבוה יותר) או ל-0 (אובדן נמוך יותר)?
- מאפסים את Playground על ידי לחיצה על החץ העקומה שמשמאל
לחצן הפעלה/השהיה.
משימה 2: מבצעים את הפעולות הבאות כדי לבנות מודל טוב יותר:
- בוחרים או מבטלים את הבחירה בכל שילוב של חמש התכונות האפשריות.
- מתאימים את קצב הלמידה.
- אימון המערכת למשך 500 תקופות של זמן לפחות.
- בודקים את הערך של Test loss. האם יכול להיות שמספר המשתמשים שהפסדת בבדיקה קטן מ-0.2?
הפתרונות מופיעים מתחת ל-Playground.
הפתרון למטלה 1
המודל גרוע. לדוגמה, שימו לב שרבים מהם
נקודות שוחות בים כחול. בנוסף, אובדן הבדיקות הוא גבוה מאוד.
הפתרון למטלה 2
כדי לשפר את ביצועי המודל, אתם יכולים:
-
בוחרים את שתי הטרנספורמציות הפולינומיות (x12 ו-x22) ומבטלים את הסימון של שלוש התכונות האפשריות האחרות.
-
צריך להוריד את קצב הלמידה ל-
0.001
ומטה.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-06-03 (שעון UTC).
[null,null,["עדכון אחרון: 2025-06-03 (שעון UTC)."],[[["\u003cp\u003ePlayground is an interactive tool for experimenting with machine learning models by adjusting features and hyperparameters to observe their impact.\u003c/p\u003e\n"],["\u003cp\u003eExercise 1 focuses on feature crosses and manipulating feature weights to achieve accurate model predictions of sick and healthy trees.\u003c/p\u003e\n"],["\u003cp\u003eExercise 2 explores model training, the influence of features and learning rate on model performance, and minimizing test loss for better predictions.\u003c/p\u003e\n"]]],[],null,["# Categorical data: Feature cross exercises\n\n[Playground](https://playground.tensorflow.org/) is an\ninteractive application that lets you manipulate various\naspects of training and testing a machine learning model.\nWith Playground, you can select features and adjust hyperparameters,\nand then discover how your choices influence a model.\n\nThis page contains two Playground exercises.\n\nExercise 1: A basic feature cross\n---------------------------------\n\nFor this exercise, focus on the following parts of the Playground\nuser interface:\n\n- Underneath FEATURES, notice the three potential model features:\n - x~1~\n - x~2~\n - x~1~x~2~\n- Underneath OUTPUT, you'll see a square containing orange and blue dots. Imagine that you're looking at a square forest, where orange dots mark the position of sick trees and blue dots mark the position of healthy trees.\n- Between FEATURES and OUTPUT, if you look very closely, you'll see three faint dashed lines connecting each feature to the output. The width of each dashed line symbolizes the weight currently associated with each feature. These lines are very faint because the starting weight for each feature is initialized to 0. As the weight grows or shrinks, so will the thickness of these lines.\n\n**Task 1:** Explore Playground by doing the following:\n\n1. Click on the faint line that connects feature x~1~ to the output. A popup appears.\n2. In the popup, enter the weight `1.0`.\n3. Press Enter.\n\nNotice the following:\n\n- The dashed line for x~1~ becomes thicker as the weight increases from 0 to 1.0.\n- An orange and blue background now appears.\n - The orange background is the model's guesses as to where the sick trees are.\n - The blue background is the model's guesses as to where the healthy trees are. The model is doing a terrible job; about half of the model's guesses are wrong.\n- Because the weight is 1.0 for x~1~ and 0 for the other features, the model matches x~1~'s values exactly.\n\n**Task 2:** Change the weights of any or all of the three features so that the\nmodel (the background colors) successfully predicts sick and healthy\ntrees. The solution appears just below Playground.\n\n\u003cbr /\u003e\n\n\n*** ** * ** ***\n\n*** ** * ** ***\n\n**Click here for the solution to Task 2** \n- *w~1~* = 0\n- *w~2~* = 0\n- *x~1~* *x~2~* = any positive value\n\nJust for fun, what happens if you input a negative value for the feature\ncross?\n\nExercise 2: A more sophisticated feature cross\n----------------------------------------------\n\nFor the second exercise, look at the arrangement of orange dots (sick trees)\nand blue dots (healthy trees) in the output model, noticing the following:\n\n- The dots form roughly spherical patterns.\n- The arrangement of dots is noisy; for example, notice the occasional blue dots in the outer sphere of orange dots. Consequently, even a great model is unlikely to correctly predict each dot.\n\n**Task 1:** Explore the Playground UI by doing the following:\n\n1. Click the Run/Pause button, which is a white triangle inside a black circle. Playground will begin training the model; observe the Epochs counter increasing.\n2. After the system has trained for at least 300 epochs, press that same Run/Pause button to pause the training.\n3. Look at the model. Is the model making good predictions? In other words, are the blue dots generally surrounded by a blue background, and are the orange dots generally surrounded by an orange background?\n4. Examine the value of Test loss, which appears just below OUTPUT. Is this value closer to 1.0 (higher loss) or closer to 0 (lower loss)?\n5. Reset Playground by pressing the curvy arrow to the left of the Run/Pause button.\n\n**Task 2:** Build a better model by doing the following:\n\n1. Select or deselect any combination of the five possible features.\n2. Adjust the learning rate.\n3. Train the system for at least 500 epochs.\n4. Examine the value of Test loss. Can you get a Test loss less than 0.2?\n\nSolutions appear below Playground.\n\n*** ** * ** ***\n\n*** ** * ** ***\n\n**Click here for the solution to Task 1** \nThe model is terrible. Notice, for example, that many of the orange\ndots are swimming in a sea of blue. Furthermore, Test loss is very high.\n**Click here for the solution to Task 2** \n\nYou can improve model performance by doing the following:\n\n- Select both polynomial transforms (x~1~^2^ and x~2~^2^) and unselect the other three possible features.\n- Reduce the learning rate to `0.001` or lower. \n[Help Center](https://support.google.com/machinelearningeducation)"]]