Skip to content

Commit

Permalink
Merge 14c87b6 into e5c906f
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Dec 3, 2020
2 parents e5c906f + 14c87b6 commit dd4a694
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mlxtend/evaluate/bootstrap_point632.py
Expand Up @@ -149,6 +149,12 @@ def bootstrap_point632_score(estimator, X, y, n_splits=200,
raise ValueError('The `method` must '
'be in %s. Got %s.' % (allowed_methods, method))

# Pandas compatibility
if hasattr(X, "values"):
X = X.values
if hasattr(y, "values"):
y = y.values

_check_arrays(X, y)

if clone_estimator:
Expand Down
16 changes: 15 additions & 1 deletion mlxtend/evaluate/tests/test_bootstrap_point632.py
Expand Up @@ -5,6 +5,7 @@
# License: BSD 3 clause

import numpy as np
import pandas as pd
import pytest
from sklearn.base import BaseEstimator
from sklearn.linear_model import LogisticRegression
Expand All @@ -22,6 +23,18 @@ def __init__(self):
pass


def test_pandas_pass():
tree = DecisionTreeClassifier(random_state=123)
X_df = pd.DataFrame(X)
y_ser = pd.Series(y)
bootstrap_point632_score(tree, X_df, y_ser,
random_seed=123, method='oob')
bootstrap_point632_score(tree, X_df, y_ser,
random_seed=123, method='.632')
bootstrap_point632_score(tree, X_df, y_ser,
random_seed=123, method='.632+')


def test_defaults():
lr = LogisticRegression(solver='liblinear', multi_class='ovr')
scores = bootstrap_point632_score(lr, X, y, random_seed=123)
Expand All @@ -32,7 +45,8 @@ def test_defaults():

def test_oob():
tree = DecisionTreeClassifier(random_state=123)
scores = bootstrap_point632_score(tree, X, y, random_seed=123, method='oob')
scores = bootstrap_point632_score(
tree, X, y, random_seed=123, method='oob')
acc = np.mean(scores)
assert len(scores == 200)
assert np.round(acc, 5) == 0.94667, np.round(acc, 5)
Expand Down

0 comments on commit dd4a694

Please sign in to comment.