[Python] dtreeviz python package is showing a split as being at 0 instead of the actual number

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    The dtreeviz python package is showing a split at .216 as "0.000" as seen in this screenshot: [​IMG]

    The code is:

    self.clf = DecisionTreeClassifier(random_state=1234, max_depth=self.treeDepth)
    viz_model = dtreeviz.model(self.clf,
    X_train=self.features, y_train=self.target,
    feature_names=self.featureColumns,
    target_name=self.targetColumn, class_names=["short", "long"])
    v = viz_model.view(scale=2, precision=4)
    v.save(path)


    The textual representation shows the splits correctly:

    Code:

    text_representation = tree.export_text(self.clf, decimals=3)


    Output:

    |--- feature_1 <= 0.216
    | |--- feature_1 <= 0.212
    | | |--- feature_1 <= 0.208
    | | | |--- class: 0
    | | |--- feature_1 > 0.208
    | | | |--- class: 1
    | |--- feature_1 > 0.212
    | | |--- class: 0
    |--- feature_1 > 0.216
    | |--- feature_1 <= 0.401
    | | |--- feature_1 <= 0.379
    | | | |--- class: 1
    | | |--- feature_1 > 0.379
    | | | |--- class: 1
    | |--- feature_1 > 0.401
    | | |--- feature_1 <= 0.430
    | | | |--- class: 0
    | | |--- feature_1 > 0.430
    | | | |--- class: 1

    Continue reading...

Compartilhe esta Página