Decision Tree - only one attribute per branch?

DBenkert
DBenkert New Altair Community Member
edited November 2024 in Community Q&A
Hello, i hope everyone here is doing great!

I have a question regarding decision trees. Is it possible to set up the decision tree in a way, so that the model will use every attribute just once per branch? I need this for a project for my studies, and it would mean a lot if someone here can help me :smile: .

Thanks in advance!

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Hi,
    not with the normal decision trees. The interactive ones may be grown like this.

    BR,
    Martin
  • machbrown2
    machbrown2 New Altair Community Member

    Hello,

    Certainly! In a One Rule decision tree:

    1. Select Best Attribute:

      • Evaluate each attribute's classification error.
      • Choose the attribute with the lowest error.
    2. Create Rule:

      • Formulate a rule based on the selected attribute.
    3. Apply Rule:

      • Classify instances based on the rule.
    4. Repeat for Each Attribute:

      • Iterate through all attributes to find the best rule.
    5. Choose Best Rule:

      • Select the rule that performs best on the data.
    6. Tree Structure:

      • The decision tree has a single level, with branches corresponding to attributes and leaf nodes representing predicted classes.

    Example in Python (using scikit-learn):

    <p>from sklearn.tree import DecisionTreeClassifier, export_text</p><p><br></p><p># Create a One Rule decision tree</p><p>tree_clf = DecisionTreeClassifier(max_depth=1)</p><p><br></p><p># Train the classifier</p><p>tree_clf.fit(X_train, y_train)</p><p><br></p><p># Display the selected rule</p><p>tree_rules = export_text(tree_clf, feature_names=iris.feature_names)</p><p>print(tree_rules)</p>




  • DBenkert
    DBenkert New Altair Community Member
    Ahh thank you so much!!! :) i really appreciate your help!

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.