This project was developed during my Master's program in Software Architecture and Design, specifically as part of the Adaptive Software Systems course. It's a simple prototype for building and interacting with a Decision Tree classifier using the ID3 algorithm.
The goal was to gain practical experience implementing machine learning models and understanding decision-making logic through code. The result is a console-based tool with features for importing/exporting data, querying a decision tree, and visualizing the results—all built around a lightweight, testable architecture.
Now, a few years later, I’ve decided to revisit and continue working on this project—improving the decision tree implementation and extending it to support regression trees as well.
- A functional decision tree builder (ID3-based)
- Console interface with import/export/query support
- Example datasets
- Basic tree visualization
- Unit tests using xUnit
- No fancy UI—just clean, testable code
The decision tree is built using the ID3 algorithm, which selects features based on Information Gain. It recursively splits the dataset until either:
- All samples belong to the same class, or
- There's no more useful info to split on
The tree can be queried using feature values to return a classification result.
BuildTree(data)
: Recursively splits data using feature with highest Information Gain.
Stop condition: Subset is homogeneous or no further gain.
Traversal starts at the root node using user-provided values until a leaf node (classification result) is reached.
To import data, use a semi-colon-separated .csv
file with a Data
tag separating headers from values. The last column should be the class label.
Swimming Suit;Water Temperature;Swim Preference
Data
None;Cold;No
Good;Warm;Yes
Swimming Suit,Water Temperature,Swim Preference
None,Cold,No
When you run the app, you'll see a terminal-based menu with the following options:
- Import Data – Load your
.csv
file - Export Data – Manually input and save data
- Query Tree – Enter feature values to get a prediction
- Help – Shows usage tips and format guide
- Display Menu – Redraw the main menu
- Print Tree – Visualize the decision tree
- Quit – Close the application
+- SWIMMING SUIT
+- none -> no
+- good -> WATER TEMPERATURE
+- cold -> no
+- warm -> yes
Included (or tested with) several datasets, including:
chess.csv
swimpreference.csv
social_network_ads.csv
species.csv
goingout.csv
Each one was adapted to match the expected file format and tested with the tree.
- With Visual Studio 2022: Open and run
- Via CLI: Run
dotnet run
in the project directory
- Built using xUnit
- Run with
dotnet test
or through Visual Studio’s Test Explorer
This is a prototype, so it's not production-ready—just a hands-on implementation for learning and exploration. It's meant to demonstrate the fundamentals of decision tree construction and traversal in a clear, testable way.
Feature | Status |
---|---|
Decision Tree (ID3) | âś… Implemented |
Regression Tree | ❌ Not implemented |
Console Interface | âś… Done |
Tree Visualization | âś… Basic console view |
Import/Export | âś… Supported |
Clean Documentation | âś… Included |
- Migrate from .NET Core 3.1 to .NET 8
- Add workflow for this project
- Refactor the Decision Tree implementation for better readability and modularity
- Implement a Regression Tree functionality