5016a008790087d9cb47e7f91099f3dba7960ee2,mlxtend/regressor/stacking_cv_regression.py,StackingCVRegressor,fit,#StackingCVRegressor#Any#Any#Any#Any#,119
Before Change
// cross-validation strategy
kfold.shuffle = self.shuffle
meta_features = np.zeros((X.shape[0], len(self.regressors)))
//
// The outer loop iterates over the base-regressors. Each regressor
// is trained cv times and makes predictions, after which we train
// the meta-regressor on their combined results.
//
for i, regr in enumerate(self.regressors):
//
// In the inner loop, each model is trained cv times on the
// training-part of this fold of data; and the holdout-part of data
// is used for predictions. This is repeated cv times, so in
// the end we have predictions for each data point.
//
// Advantage of this complex approach is that data points we"re
// predicting have not been trained on by the algorithm, so it"s
// less susceptible to overfitting.
//
for train_idx, holdout_idx in kfold.split(X, y, groups):
instance = clone(regr)
if sample_weight is None:
instance.fit(X[train_idx], y[train_idx])
else:
instance.fit(X[train_idx], y[train_idx],
sample_weight=sample_weight[train_idx])
y_pred = instance.predict(X[holdout_idx])
meta_features[holdout_idx, i] = y_pred
// save meta-features for training data
if self.store_train_meta_features:
self.train_meta_features_ = meta_features
// Train meta-model on the out-of-fold predictions
After Change
// predicting have not been trained on by the algorithm, so it"s
// less susceptible to overfitting.
if sample_weight is None:
fit_params = None
else:
fit_params = dict(sample_weight=sample_weight)
meta_features = np.column_stack([cross_val_predict(
regr, X, y, groups=groups, cv=kfold,
n_jobs=self.n_jobs, fit_params=fit_params,
pre_dispatch=self.pre_dispatch)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 9
Instances Project Name: rasbt/mlxtend
Commit Name: 5016a008790087d9cb47e7f91099f3dba7960ee2
Time: 2019-03-14
Author: 36086881+qiagu@users.noreply.github.com
File Name: mlxtend/regressor/stacking_cv_regression.py
Class Name: StackingCVRegressor
Method Name: fit
Project Name: regel/loudml
Commit Name: 0457beb9a9ab772fa3d2a4b74ca6abf98205ff4b
Time: 2018-04-30
Author: sebastien.regel@gmail.com
File Name: loudml/loudml/fingerprints.py
Class Name: FingerprintsModel
Method Name: predict
Project Name: regel/loudml
Commit Name: 0457beb9a9ab772fa3d2a4b74ca6abf98205ff4b
Time: 2018-04-30
Author: sebastien.regel@gmail.com
File Name: loudml/loudml/fingerprints.py
Class Name: FingerprintsModel
Method Name: train