Skip to content

Commit

Permalink
Merge pull request #725 from hanzigs/master
Browse files Browse the repository at this point in the history
Keras Sequential Model Support for Bias Variance Computation
  • Loading branch information
Sebastian Raschka committed Sep 11, 2020
2 parents 8eb6954 + 81e7a87 commit a6ff5b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/sources/CHANGELOG.md
Expand Up @@ -19,7 +19,8 @@ The CHANGELOG for the current development version is available at

##### New Features

- -
- The `bias_variance_decomp` now supports Keras estimators. ([#725](https://github.com/rasbt/mlxtend/pull/725) via [@hanzigs](https://github.com/hanzigs))


##### Changes

Expand Down
6 changes: 5 additions & 1 deletion mlxtend/evaluate/bias_variance_decomp.py
Expand Up @@ -74,7 +74,11 @@ def bias_variance_decomp(estimator, X_train, y_train, X_test, y_test,

for i in range(num_rounds):
X_boot, y_boot = _draw_bootstrap_sample(rng, X_train, y_train)
pred = estimator.fit(X_boot, y_boot).predict(X_test)
if estimator.__class__.__name__ == 'Sequential':
estimator.fit(X_boot, y_boot)
pred = estimator.predict(X_test).reshape(1, -1)
else:
pred = estimator.fit(X_boot, y_boot).predict(X_test)
all_pred[i] = pred

if loss == '0-1_loss':
Expand Down

0 comments on commit a6ff5b8

Please sign in to comment.