Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: dict() argument after ** must be a mapping, not float #285

Closed
RajdeepTarafder opened this issue Apr 3, 2023 · 2 comments
Closed
Milestone

Comments

@RajdeepTarafder
Copy link

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

@Alex-AMC
Copy link
Contributor

Alex-AMC commented Apr 7, 2023

I had the same error

@parrt
Copy link
Owner

parrt commented Apr 7, 2023

Fixed by #286

@parrt parrt closed this as completed Apr 7, 2023
@parrt parrt added this to the 2.2.1 milestone Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants