You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Classification with class labels](https://github.com/vecxoz/vecstack/blob/master/examples/02_classification_with_class_labels.ipynb)
26
27
* <sup>**MUST SEE**</sup> [Classification with probabilities + Detailed workflow](https://github.com/vecxoz/vecstack/blob/master/examples/03_classification_with_proba_detailed_workflow.ipynb)
27
-
* Explanation of [**stacking concept**](https://github.com/vecxoz/vecstack#stacking-concept) with pictures
28
28
* You can also look at detailed [parameter description](https://github.com/vecxoz/vecstack/blob/master/vecstack/core.py#L136) or just type ```>>>help(stacking)```
29
29
30
30
# Installation
@@ -235,23 +235,42 @@ Final prediction score: [0.96666667]
235
235
236
236
# Stacking concept
237
237
238
-
1. We want to predict train and test sets with some 1st level model(s), and then use this predictions as features for 2nd level model.
238
+
1. We want to predict train set and test set with some 1st level model(s), and then use these predictions as features for 2nd level model(s).
239
239
2. Any model can be used as 1st level model or 2nd level model.
240
-
3. To avoid overfitting (for train set) we use cross-validation technique and in each fold we predict out-of-fold part of train set.
240
+
3. To avoid overfitting (for train set) we use cross-validation technique and in each fold we predict out-of-fold (OOF) part of train set.
241
241
4. The common practice is to use from 3 to 10 folds.
242
-
5. In each fold we predict full test set, so after completion of all folds we need to find mean (mode) of all test set predictions made in each fold. (Alternatively we can fit model on full train set and predict test set once. This approach takes more time because we need to perform one additional fitting, but may give higher test accuracy because we can use all train data for fitting.)
242
+
5. Predict test set:
243
+
***Variant A:** In each fold we predict test set, so after completion of all folds we need to find mean (mode) of all temporary test set predictions made in each fold.
244
+
***Variant B:** We do not predict test set during cross-validation cycle. After completion of all folds we perform additional step: fit model on full train set and predict test set once. This approach takes more time because we need to perform one additional fitting.
243
245
6. As an example we look at stacking implemented with single 1st level model and 3-fold cross-validation.
244
-
7. Three pictures below describe three folds of cross-validation. After completion of all three folds we get single train feature and single test feature to use with 2nd level model.
246
+
7. Pictures:
247
+
***Variant A:** Three pictures describe three folds of cross-validation. After completion of all three folds we get single train feature and single test feature to use with 2nd level model.
248
+
***Variant B:** First three pictures describe three folds of cross-validation (like in Variant A) to get single train feature and fourth picture describes additional step to get single test feature.
245
249
8. We can repeat this cycle using other 1st level models to get more features for 2nd level model.
246
-
9.At the bottom you can see [GIF animation](https://github.com/vecxoz/vecstack#animation).
250
+
9.You can also look at animation of [Variant A](https://github.com/vecxoz/vecstack#variant-a.-animation) and [Variant B](https://github.com/vecxoz/vecstack#variant-b.-animation).
247
251
252
+
# Variant A
253
+
254
+

248
255
***
249
-

256
+

250
257
***
251
-

258
+

259
+
260
+
# Variant A. Animation
261
+
262
+

263
+
264
+
# Variant B
265
+
266
+

267
+
***
268
+

252
269
***
253
-

270
+

254
271
***
272
+

0 commit comments