def plot_svm_decision_function(svm: SVM.NuSVR, x_test: np.array, y_test: np.array, fig_name: str) -> None: interval = [-5.5, 6] xx, yy = np.meshgrid(np.linspace(interval[0], interval[1], 500), np.linspace(interval[0], interval[1], 500)) # plot the decision function for each datapoint on the grid Z = svm.decision_function(np.c_[xx.ravel(), yy.ravel()]) Z = Z.reshape(xx.shape) pyplot.figure(fig_name) pyplot.title(fig_name) pyplot.imshow(Z, interpolation='nearest', extent=(xx.min(), xx.max(), yy.min(), yy.max()), aspect='auto', origin='lower', cmap=pyplot.cm.PuOr_r) pyplot.contour(xx, yy, Z, levels=[0], linewidths=2, linestyles='dashed') pyplot.scatter(x_test[:, 0], x_test[:, 1], s=30, c=y_test, cmap=pyplot.cm.Paired, edgecolors='k') pyplot.xticks(()) pyplot.yticks(()) pyplot.axis([interval[0], interval[1], interval[0], interval[1]]) pyplot.savefig("graficos/" + fig_name, format="png") pyplot.show()