Skip to content

A comprehensive PyQt5-based desktop application for designing, visualizing, and simulating decision trees. This tool provides an intuitive graphical interface for creating complex decision logic flows with visual execution tracing. Visual editor and simulator for decision trees and logic flows. Desktop GUI written in Python with PyQt5.

License

Notifications You must be signed in to change notification settings

BaseMax/qt-decision-tree-studio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Decision Tree Studio

A comprehensive PyQt5-based desktop application for designing, visualizing, and simulating decision trees. This tool provides an intuitive graphical interface for creating complex decision logic flows with visual execution tracing.

License Python PyQt5

Features

Core Features

  • 🎨 Visual Node Editor: Drag-and-drop interface for creating decision trees
  • πŸ”€ Multiple Node Types: Start, Decision, Action, and End nodes
  • βš™οΈ Condition Builder: Create complex conditions with various operators
  • 🎯 Execution Tracing: Step-by-step visualization of decision tree execution
  • πŸ“Š Statistics Panel: Real-time tree metrics and analysis
  • πŸ’Ύ Import/Export: Save and load trees in JSON format
  • πŸ” Zoom & Pan: Navigate large trees with ease

Node Types

  1. Start Node: Entry point of the decision tree (green, rounded)
  2. Decision Node: Conditional branching based on variables (blue, diamond)
  3. Action Node: Execute actions or operations (yellow, rectangle)
  4. End Node: Terminal node in the tree (red, rounded)

Condition Operators

  • == Equal to
  • != Not equal to
  • > Greater than
  • < Less than
  • >= Greater than or equal to
  • <= Less than or equal to
  • contains String containment check

Installation

Prerequisites

  • Python 3.6 or higher
  • pip package manager

Install Dependencies

pip install -r requirements.txt

Or install PyQt5 directly:

pip install PyQt5>=5.15.0

Usage

Running the Application

python main.py

Or make it executable (Linux/Mac):

chmod +x main.py
./main.py

Creating a Decision Tree

  1. Add Nodes:

    • Right-click on canvas β†’ "Add Node" β†’ Select node type
    • Or use toolbar buttons to add nodes at center
    • Or use Edit menu β†’ "Add Node"
  2. Edit Nodes:

    • Right-click on a node β†’ "Edit Node"
    • Configure label, conditions (for decision nodes), or actions (for action nodes)
  3. Connect Nodes:

    • Right-click on a node β†’ "Connect To" β†’ Select target node
    • For decision nodes: Choose "Connect True Branch" or "Connect False Branch"
  4. Move Nodes:

    • Click and drag nodes to reposition them
    • Use mouse wheel to zoom in/out
    • Click and drag on empty space to pan

Executing a Decision Tree

  1. Click "Execute" in toolbar or press F5
  2. Enter variable values in the execution dialog:
    age = 25
    score = 85.5
    name = John
    
  3. Click OK to execute
  4. View execution path highlighted in red on the canvas
  5. Check execution trace in the bottom panel

Saving and Loading

  • New Tree: File β†’ New (Ctrl+N)
  • Open Tree: File β†’ Open (Ctrl+O)
  • Save Tree: File β†’ Save (Ctrl+S)
  • Save As: File β†’ Save As (Ctrl+Shift+S)
  • Export JSON: File β†’ Export JSON
  • Import JSON: File β†’ Import JSON

File Format

Trees are saved in JSON format with the following structure:

{
  "name": "My Decision Tree",
  "root_id": "node_id",
  "nodes": {
    "node_id": {
      "id": "node_id",
      "type": "decision",
      "label": "Check Age",
      "position": [100, 200],
      "condition": {
        "variable": "age",
        "operator": ">=",
        "value": "18"
      },
      "true_child": "true_node_id",
      "false_child": "false_node_id"
    }
  }
}

Keyboard Shortcuts

  • Ctrl+N - New tree
  • Ctrl+O - Open tree
  • Ctrl+S - Save tree
  • Ctrl+Shift+S - Save tree as
  • F5 - Execute tree
  • Ctrl++ - Zoom in
  • Ctrl+- - Zoom out
  • Ctrl+0 - Reset zoom
  • Ctrl+Q - Quit application

Example Use Cases

Age Verification System

Start β†’ Check Age β†’ (age >= 18) β†’ True: Grant Access / False: Deny Access β†’ End

Grading System

Start β†’ Check Score β†’ (score >= 90) β†’ True: Grade A
                    β†’ False: Check Score β†’ (score >= 80) β†’ True: Grade B
                                         β†’ False: Check Score β†’ (score >= 70) β†’ True: Grade C
                                                              β†’ False: Grade F

Product Recommendation

Start β†’ Check Budget β†’ (budget > 1000) β†’ True: Premium Products
                                       β†’ False: Check Category β†’ (category == "electronics") β†’ ...

Project Structure

qt-decision-tree-studio/
β”œβ”€β”€ main.py              # Application entry point
β”œβ”€β”€ main_window.py       # Main window with menus and panels
β”œβ”€β”€ models.py            # Data models (TreeNode, DecisionTree, Condition)
β”œβ”€β”€ graphics.py          # Graphical node and edge widgets
β”œβ”€β”€ canvas.py            # Canvas scene and view for tree visualization
β”œβ”€β”€ dialogs.py           # Dialog windows (node editor, execution)
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ README.md            # This file
└── LICENSE              # MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Max Base

Acknowledgments

  • Built with PyQt5
  • Inspired by visual programming tools and decision tree algorithms

About

A comprehensive PyQt5-based desktop application for designing, visualizing, and simulating decision trees. This tool provides an intuitive graphical interface for creating complex decision logic flows with visual execution tracing. Visual editor and simulator for decision trees and logic flows. Desktop GUI written in Python with PyQt5.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages