There is a code for the decision tree classifier. I display several graphs in it. I call the graphs through functions with the definition of arguments. The problem is that the next chart doesn't open until I close the previous one. The problem went further, when using the tkinter, the second graph does not appear there at all, even if I close the first one.
Some code:
def visualize_classifier(classifier, x, y, heading = None, view_result = None):
min_x, max_x = x[:, 0].min() - 1.0, x[:, 0].max() + 1.0
min_y, max_y = x[:, 1].min() - 1.0, x[:, 1].max() + 1.0
mesh_step_size = 0.01
x_vals, y_vals = np.meshgrid(np.arange(min_x, max_x, mesh_step_size), np.arange(min_y, max_y, mesh_step_size))
output = classifier.predict(np.c_[x_vals.ravel(), y_vals.ravel()])
output = output.reshape(x_vals.shape)
plt.figure()
plt.pcolormesh(x_vals, y_vals, output, cmap=plt.cm.gray)
plt.scatter(x[:, 0], x[:, 1], c=y, s=75, edgecolors='black', linewidth=1, cmap=plt.cm.Paired)
plt.xlim(x_vals.min(), x_vals.max())
plt.ylim(y_vals.min(), y_vals.max())
plt.xticks((np.arange(int(x[:, 0].min() - 1), int(x[:, 0].max() + 1), 1.0)))
plt.yticks((np.arange(int(x[:, 1].min() - 1), int(x[:, 1].max() + 1), 1.0)))
if view_result != None:
plt.xlabel(view_result)
if heading != None:
plt.title(heading)
plt.tight_layout()
plt.show()
def input_data_visualization(class_0, class_1):
# Визуализация входных данных
plt.figure()
plt.scatter(class_0[:, 0], class_0[:, 1], s=75, facecolors='black',
edgecolors='black', linewidth=1, marker='x')
plt.scatter(class_1[:, 0], class_1[:, 1], s=75, facecolors='white',
edgecolors='black', linewidth=1, marker='o')
plt.title('Input data')
plt.show()
def decision_tree_classifier():
.
.
.
input_data_visualization(class_0, class_1)
visualize_classifier(classifier, X_train, y_train, 'Training dataset')
visualize_classifier(classifier, X_test, y_test, 'Test dataset')
Next, I use a tkinter to build an interface with buttons. I upload the file and click on the button to calculate and output 3 graphs. But only the first is displayed, when you close it, nothing else happens. There is an idea to simply use a call to several functions at the same time on a button, but this is probably not entirely correct?
ps. just tried to separate all these functions and call them through one button - the result is the same, only one graph appears