INNER CODE UNIT · Python

X_flatten

ankonzoid/LearningX · advanced_ML/tree_ensembles/tree_ensembles.py:48

                X_flatten = X.reshape((-1,))
                plt.plot(X_flatten, y, 'ok', markersize=5, label='data')
                plt.plot(X_flatten, y_pred, 'or', markersize=3, linewidth=3, label='pred')
                plt.title('(n_estimators, depth) = ({}, {})'.format(
                    n_estimators_vec[j], max_depth_vec[i]))
                plt.tick_params(
                    axis='both', which='both',
                    bottom=False, left=False, top=False,
                    labelbottom=False, labelleft=False)
        plt.suptitle("{} predictions".format(name), fontsize=30)
        plt.legend(bbox_to_anchor=(1.05, 0), loc='lower left', borderaxespad=0.)
        plt.savefig(plot_filename + ".png", bbox_inches=None)  # supports ".pdf" too
        plt.close()

    plot_model(BaggedTreeRegressor, X, y, "output/bagged_trees",
               n_estimators_vec=[1, 25, 50], max_depth_vec=[2, 4, 6], name="Bagged Trees")
    plot_model(RandomForestTreeRegressor, X, y, "output/random_forest",
               n_estimators_vec=[1, 25, 50], max_depth_vec=[2, 4, 6], name="Random Forest")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…