2
$\begingroup$

I am referring to this sample (http://scikit-learn.org/stable/auto_examples/ensemble/plot_feature_transformation.html#sphx-glr-auto-examples-ensemble-plot-feature-transformation-py) for the context.

Specifically for below part of code, in the sample of the link, the method of (1) using Boosting tree to generate feature, then using LR to train, outperforms (2) using Boosting tree itself. Questions,

  1. Wondering if it is true in general case using Boosting tree to generate feature (and using another classifier to classify) is better than using Boosting tree to do classification itself?
  2. And also wondering why using Boosting tree to generate feature, then using LR to train, outperforms using Boosting tree itself?

$\;$

grd = GradientBoostingClassifier(n_estimators=n_estimator)
grd_enc = OneHotEncoder()
grd_lm = LogisticRegression()
grd.fit(X_train, y_train)
grd_enc.fit(grd.apply(X_train)[:, :, 0])
grd_lm.fit(grd_enc.transform(grd.apply(X_train_lr)[:, :, 0]), y_train_lr)
$\endgroup$
2
  • $\begingroup$ BTW, I am trying to format code, but it seems format is still wrong. If anyone could help, it will be great. $\endgroup$
    – Lin Ma
    May 1, 2018 at 4:06
  • $\begingroup$ Thanks for the edit! $\endgroup$
    – Lin Ma
    May 1, 2018 at 7:12

0

You must log in to answer this question.

Browse other questions tagged .