2. Apply Decision Trees to a Real Case

This page uses a fictional stock dataset to build a classification tree and test its rules.

Allow 10–20 minutes. Use the fictional stock dataset below to draw a flowchart and classify a new entry. A stock is a share in a company. Here, “Buy” is the category to predict in a teaching exercise.

Read the columns: volatility describes how much prices fluctuate; analyst rating records a Buy, Neutral, or Sell opinion; trend records whether the price moves up or down. The final Buy: Yes/No column is the label the tree must predict. It is separate from the analyst’s opinion.

StockVolatilityAnalyst RatingTrendBuy
1HighBuyUpYes
2ModerateNeutralDownNo
3LowSellDownNo
4HighBuyUpYes
5HighSellDownNo
6ModerateBuyUpYes
7LowNeutralUpYes
8ModerateSellUpNo
9LowNeutralDownNo
10ModerateBuyUpYes
11LowSellUpNo
12HighNeutralUpYes
13LowBuyDownYes
14HighBuyDownNo
  1. Use Buy: Yes/No as the target class. Start by testing Analyst Rating.
  2. Draw branches for Buy, Neutral, and Sell. Add volatility or trend questions where the target class is still mixed.
  3. Follow your tree for all 14 rows. Revise any rule that does not match the dataset.
  4. Test a new case: High volatility, Buy rating, Down trend. Explain the path and result.
  5. Write what further evidence you would need before trusting the tree on new data.
See One Tree That Fits the Dataset
PathClass
Rating = SellNo
Rating = Neutral and trend = UpYes
Rating = Neutral and trend = DownNo
Rating = Buy and volatility = Moderate or LowYes
Rating = Buy and volatility = High and trend = UpYes
Rating = Buy and volatility = High and trend = DownNo

The new case follows Buy → High volatility → Down trend → No. This is one tree consistent with all 14 rows, rather than proof of how it will perform outside this teaching dataset.

You have identified uncertainty, examined assumptions, compared trade-offs and tested rules. Section E applies this toolkit to quantum threats, where a reliable timeline is unavailable.