Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Jan 2, 2024
1 parent ba4a9ae commit e07db97
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 2023/machine_learning/mglearn/plot_interactive_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def tree_image(tree, fout=None):
if fout is None:
fout = "tmp"
graph.render(fout)
return imread(fout + ".png")
return imread(f"{fout}.png")


def plot_tree_progressive():
Expand Down
2 changes: 1 addition & 1 deletion 2023/machine_learning/mglearn/plot_tree_nonmonotonous.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def plot_tree_not_monotone():
export_graphviz(tree, out_file="mytree.dot", impurity=False, filled=True)
with open("mytree.dot") as f:
dot_graph = f.read()
print("Feature importances: %s" % tree.feature_importances_)
print(f"Feature importances: {tree.feature_importances_}")
return graphviz.Source(dot_graph)
5 changes: 1 addition & 4 deletions 2023/machine_learning/mglearn/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ def heatmap(values, xlabel, ylabel, xticklabels, yticklabels, cmap=None,

for p, color, value in zip(img.get_paths(), img.get_facecolors(), img.get_array()):
x, y = p.vertices[:-2, :].mean(0)
if np.mean(color[:3]) > 0.5:
c = 'k'
else:
c = 'w'
c = 'k' if np.mean(color[:3]) > 0.5 else 'w'
ax.text(x, y, fmt % value, color=c, ha="center", va="center")
return img

Expand Down

0 comments on commit e07db97

Please sign in to comment.