Last active
September 30, 2019 07:21
-
-
Save roncho12/d535312743b13d9f89e226a12efbb049 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from mlxtend.evaluate import bootstrap_point632_score | |
from sklearn.metrics import recall_score | |
from sklearn.datasets import make_classification | |
from sklearn.linear_model import LogisticRegression | |
# Create a dataset | |
X, y = make_classification(n_samples=1000, n_features=5, n_redundant=0) | |
# Add some noise to the features | |
X += np.random.normal(0, 2.5, X.shape) | |
# Use a Logistic regression classifier | |
clf = LogisticRegression(solver='lbfgs') | |
# Run the bootstrap simulation | |
scores = bootstrap_point632_score(clf, X, y, scoring_func=recall_score, method='.632') | |
# bootstrap estimate of the recall | |
print(np.mean(scores)) | |
#percentile based 95% confidence interval | |
lower = np.percentile(scores, 2.5) | |
upper = np.percentile(scores, 97.5) | |
print(lower, upper) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment