Skip to content

Commit

Permalink
Solve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturoAmorQ committed May 7, 2024
2 parents 99bed3b + b274fd2 commit d357154
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions python_scripts/ensemble_gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# ---

# %% [markdown]
# # Gradient-boosting decision tree (GBDT)
# # Gradient-boosting decision tree
#
# In this notebook, we present the gradient boosting decision tree algorithm.
# In this notebook, we present the gradient boosting decision tree (GBDT) algorithm.
#
# Even if AdaBoost and GBDT are both boosting algorithms, they are different in
# nature: the former assigns weights to specific samples, whereas GBDT fits
# succesive decision trees on the residual errors (hence the name "gradient") of
# successive decision trees on the residual errors (hence the name "gradient") of
# their preceding tree. Therefore, each new tree in the ensemble tries to refine
# its predictions by specifically addressing the errors made by the previous
# learner, instead of predicting the target directly.
Expand Down Expand Up @@ -88,7 +88,7 @@ def generate_data(n_samples=50):
def plot_decision_tree_with_residuals(y_train, y_train_pred, y_test_pred):
"""Plot the synthetic data, predictions, and residuals for a decision tree.
Handles are used to create custom legends for the plot."""
fig, ax = plt.subplots()
_fig_, ax = plt.subplots()
# plot the data
sns.scatterplot(
x=data_train["Feature"], y=y_train, color="black", alpha=0.5, ax=ax
Expand All @@ -109,6 +109,7 @@ def plot_decision_tree_with_residuals(y_train, y_train_pred, y_test_pred):
return handles, ax


# %%
handles, ax = plot_decision_tree_with_residuals(
target_train, target_train_predicted, target_test_predicted
)
Expand Down Expand Up @@ -259,7 +260,7 @@ def plot_decision_tree_with_residuals(y_train, y_train_pred, y_test_pred):
# second tree corrects the first tree's error, while the third tree corrects the
# second tree's error and so on).
#
# ## First comparison of GBDT vs random forests
# ## First comparison of GBDT vs. random forests
#
# We now compare the generalization performance of random-forest and gradient
# boosting on the California housing dataset.
Expand Down

0 comments on commit d357154

Please sign in to comment.