Closed RajdeepTarafder closed 1 year ago
File ~\Proj\Geochem_Elemen_lysis\Geochem_Lyis\client..\model\classification.py:485, in XgboostClassification.plot(self, label_names) 482 print("----- Xgboost's Tree Plot -----") 484 columns_name = ClassificationWorkflowBase.X.columns.tolist() --> 485 viz = dtreeviz(self.model,ClassificationWorkflowBase.X, ClassificationWorkflowBase.y, 486 target_name="Labels", 487 feature_names=columns_name, 488 class_names=label_names, 489 orientation='LR', 490 show_node_labels=True, 491 tree_index=0) 492 fig = viz.view() 493 save_fig_tree(fig, 'plot_xgboost_tree', MODEL_OUTPUT_IMAGE_PATH)
File ~\AppData\Roaming\Python\Python310\site-packages\dtreeviz\compatibility.py:254, in dtreeviz(tree_model, X_train, y_train, feature_names, target_name, class_names, tree_index, precision, orientation, instance_orientation, show_root_edge_labels, show_node_labels, show_just_path, fancy, histtype, highlight_path, X, max_X_features_LR, max_X_features_TD, depth_range_to_display, label_fontsize, ticks_fontsize, fontname, title, title_fontsize, colors, scale) 251 shadow_tree = ShadowDecTree.get_shadow_tree(tree_model, X_train, y_train, feature_names, target_name, class_names, 252 tree_index) 253 model = DTreeVizAPI(shadow_tree) --> 254 return model.view(precision, orientation, 255 instance_orientation, 256 show_root_edge_labels, show_node_labels, show_just_path, fancy, histtype, highlight_path, X, 257 max_X_features_LR, max_X_features_TD, depth_range_to_display, label_fontsize, ticks_fontsize, 258 fontname, title, title_fontsize, colors, scale)
File ~\AppData\Roaming\Python\Python310\site-packages\dtreeviz\trees.py:462, in DTreeVizAPI.view(self, precision, orientation, instance_orientation, show_root_edge_labels, show_node_labels, show_just_path, fancy, histtype, leaftype, highlight_path, x, max_X_features_LR, max_X_features_TD, depth_range_to_display, label_fontsize, ticks_fontsize, fontname, title, title_fontsize, colors, scale) 459 return self.shadow_tree.leaves 461 n_classes = self.shadow_tree.nclasses() --> 462 colors = adjust_colors(colors, n_classes) 464 if orientation == "TD": 465 ranksep = ".2"
File ~\AppData\Roaming\Python\Python310\site-packages\dtreeviz\colors.py:119, in adjust_colors(colors, n_classes, cmp) 116 COLORS["classes"] = get_hex_colors(n_classes, cmp) 117 return COLORS --> 119 return dict(COLORS, **colors)
TypeError: dict() argument after ** must be a mapping, not float
I had the same error
Fixed by https://github.com/parrt/dtreeviz/pull/286
File ~\Proj\Geochem_Elemen_lysis\Geochem_Lyis\client..\model\classification.py:485, in XgboostClassification.plot(self, label_names) 482 print("----- Xgboost's Tree Plot -----") 484 columns_name = ClassificationWorkflowBase.X.columns.tolist() --> 485 viz = dtreeviz(self.model,ClassificationWorkflowBase.X, ClassificationWorkflowBase.y, 486 target_name="Labels", 487 feature_names=columns_name, 488 class_names=label_names, 489 orientation='LR', 490 show_node_labels=True, 491 tree_index=0) 492 fig = viz.view() 493 save_fig_tree(fig, 'plot_xgboost_tree', MODEL_OUTPUT_IMAGE_PATH)
File ~\AppData\Roaming\Python\Python310\site-packages\dtreeviz\compatibility.py:254, in dtreeviz(tree_model, X_train, y_train, feature_names, target_name, class_names, tree_index, precision, orientation, instance_orientation, show_root_edge_labels, show_node_labels, show_just_path, fancy, histtype, highlight_path, X, max_X_features_LR, max_X_features_TD, depth_range_to_display, label_fontsize, ticks_fontsize, fontname, title, title_fontsize, colors, scale) 251 shadow_tree = ShadowDecTree.get_shadow_tree(tree_model, X_train, y_train, feature_names, target_name, class_names, 252 tree_index) 253 model = DTreeVizAPI(shadow_tree) --> 254 return model.view(precision, orientation, 255 instance_orientation, 256 show_root_edge_labels, show_node_labels, show_just_path, fancy, histtype, highlight_path, X, 257 max_X_features_LR, max_X_features_TD, depth_range_to_display, label_fontsize, ticks_fontsize, 258 fontname, title, title_fontsize, colors, scale)
File ~\AppData\Roaming\Python\Python310\site-packages\dtreeviz\trees.py:462, in DTreeVizAPI.view(self, precision, orientation, instance_orientation, show_root_edge_labels, show_node_labels, show_just_path, fancy, histtype, leaftype, highlight_path, x, max_X_features_LR, max_X_features_TD, depth_range_to_display, label_fontsize, ticks_fontsize, fontname, title, title_fontsize, colors, scale) 459 return self.shadow_tree.leaves 461 n_classes = self.shadow_tree.nclasses() --> 462 colors = adjust_colors(colors, n_classes) 464 if orientation == "TD": 465 ranksep = ".2"
File ~\AppData\Roaming\Python\Python310\site-packages\dtreeviz\colors.py:119, in adjust_colors(colors, n_classes, cmp) 116 COLORS["classes"] = get_hex_colors(n_classes, cmp) 117 return COLORS --> 119 return dict(COLORS, **colors)
TypeError: dict() argument after ** must be a mapping, not float