def plot_boost_i(pos, i): plt.subplot(2, nb_subplot, pos + nb_subplot, label=str(i)) style_figs.light_axis() y_loss = [int(x) for x in np.abs(y - y_pred) * 100] plt.scatter(X, y, color='grey', edgecolor='k', s=y_loss) y_pred_i = adaboost[-1].estimators_[i - 1].predict(X) plt.plot(X, y_pred_i, color='orange')
def plot_bagging3(plot_line=False, new_point=False): col_sep = 'grey' # 1 plt.subplot(1, 3, 1) style_figs.light_axis() circle = [[1, 1], [1, 3], [1.5, 2], [5, 5.8]] square = [[3, 1], [3, 4], [3.5, 2], [5, 1]] plot_bagging(circle, square, new_point=new_point) if plot_line: plt.plot([2.3, 2.3], [0, 7], col_sep, ls='--') # 2 plt.subplot(1, 3, 2) style_figs.light_axis() circle = [[.5, 6], [2, 5.6], [4, 5.5], [5, 5.8]] square = [[3, 1], [3.5, 2], [6.2, 3], [4.8, 2.8]] plot_bagging(circle, square, new_point=new_point) if plot_line: plt.plot([0, 7], [4, 4], col_sep, ls='--') # 3 plt.subplot(1, 3, 3) style_figs.light_axis() circle = [[1, 1], [1.5, 2], [1.4, 4.4], [3, 6.5], [4, 5.5]] square = [[3, 1], [5, 4.5], [5, 1], [6.2, 3]] if plot_line: plt.plot([4.5, 4.5], [0, 7], col_sep, ls='--') plot_bagging(circle, square, new_point=new_point) style_figs.light_axis()
# Create linear regression object regr = linear_model.LinearRegression() regr.fit(x.reshape((-1, 1)), y) plt.scatter(x, y, color='k', s=9) plt.plot([-1, 1], regr.predict([[ -1, ], [ 1, ]]), linewidth=3) plt.axis('tight') plt.xlim(-1, 1) ymin, ymax = plt.ylim() style_figs.light_axis() plt.ylabel('y', size=16, weight=600) plt.xlabel('x', size=16, weight=600) plt.savefig('ols_simple.svg', facecolor='none', edgecolor='none') plt.scatter(x_test, y_test, color='C1', s=9, zorder=20, alpha=.4) plt.xlim(-1, 1) plt.ylim(ymin, ymax) plt.savefig('ols_simple_test.svg', facecolor='none', edgecolor='none') # %% # Plot cubic splines plt.clf() ax = plt.axes([.1, .1, .9, .9])
def plot_boost(pos, size=None): plt.subplot(2, nb_subplot, pos, label=str(i) + str(size)) style_figs.light_axis() plt.scatter(X, y, color='grey', edgecolor='k', s=size) plt.plot(X, y_pred, color='blue')