INNER CODE UNIT · Python

plot_model_tree_fit

ankonzoid/LearningX · advanced_ML/model_tree/run_tests.py:50

def plot_model_tree_fit(model, X, y):
        output_filename = os.path.join("output", "test_{}_fit.png".format(model.__class__.__name__))
        print("Saving model tree predictions plot y vs x to '{}'...".format(output_filename))

        plt.figure(figsize=(20, 10))
        figure_str = "23"
        for depth in range(6):
            # Form model tree
            print(" -> training model tree depth={}...".format(depth))
            model_tree = ModelTree(model, max_depth=depth, min_samples_leaf=10,
                                   search_type="greedy", n_search_grid=100)

            # Train model tree
            model_tree.fit(X, y, verbose=False)
            y_pred = model_tree.predict(X)

            # Plot predictions
            plt.subplot(int(figure_str + str(depth + 1)))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…