Categorical data: Feature cross exercises
Stay organized with collections
Save and categorize content based on your preferences.
Playground is an
interactive application that lets you manipulate various
aspects of training and testing a machine learning model.
With Playground, you can select features and adjust hyperparameters,
and then discover how your choices influence a model.
This page contains two Playground exercises.
Exercise 1: A basic feature cross
For this exercise, focus on the following parts of the Playground
user interface:
- Underneath FEATURES, notice the three potential model features:
- 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.
- 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.
Task 1: Explore Playground by doing the following:
- Click on the faint line that connects feature x1 to the output.
A popup appears.
- In the popup, enter the weight
1.0
.
- Press Enter.
Notice the following:
- The dashed line for x1 becomes thicker as the weight increases
from 0 to 1.0.
- An orange and blue background now appears.
- The orange background is the model's guesses as to where the sick trees
are.
- 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.
- Because the weight is 1.0 for x1 and 0 for the other features,
the model matches x1's values exactly.
Task 2: Change the weights of any or all of the three features so that the
model (the background colors) successfully predicts sick and healthy
trees. The solution appears just below Playground.
Click here for the solution to Task 2
- w1 = 0
- w2 = 0
- x1 x2 = any positive value
Just for fun, what happens if you input a negative value for the feature
cross?
Exercise 2: A more sophisticated feature cross
For the second exercise, look at the arrangement of orange dots (sick trees)
and blue dots (healthy trees) in the output model, noticing the following:
- The dots form roughly spherical patterns.
- 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.
Task 1: Explore the Playground UI by doing the following:
- 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.
- After the system has trained for at least 300 epochs, press that same
Run/Pause button to pause the training.
- 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?
- 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)?
- Reset Playground by pressing the curvy arrow to the left of the
Run/Pause button.
Task 2: Build a better model by doing the following:
- Select or deselect any combination of the five possible features.
- Adjust the learning rate.
- Train the system for at least 500 epochs.
- Examine the value of Test loss. Can you get a Test loss less than 0.2?
Solutions appear below Playground.
Click here for the solution to Task 1
The model is terrible. Notice, for example, that many of the orange
dots are swimming in a sea of blue. Furthermore, Test loss is very high.
Click here for the solution to Task 2
You can improve model performance by doing the following:
-
Select both polynomial transforms
(x12 and x22) and unselect
the other three possible features.
-
Reduce the learning rate to
0.001
or lower.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-25 UTC.
[null,null,["Last updated 2025-08-25 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)"]]