Created
January 17, 2013 04:23
-
-
Save mrorii/4553636 to your computer and use it in GitHub Desktop.
Simple script for checking whether estimators call check_arrays in fit
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
Estimator Calls check_arrays? | |
RandomForestClassifier True | |
RBFSampler False | |
LDA True | |
GaussianNB True | |
LinearSVC False | |
SVC False |
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
#!/usr/bin/env python | |
import mock | |
import sklearn.utils | |
sklearn.utils.check_arrays = mock.Mock(return_value=100) | |
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.kernel_approximation import RBFSampler | |
from sklearn.lda import LDA | |
from sklearn.naive_bayes import GaussianNB | |
from sklearn.svm import LinearSVC | |
from sklearn.svm import SVC | |
def main(): | |
X = [[1,1], [1,0], [0,0], [0,1]] | |
Y = [1,1,0,0] | |
estimators = [RandomForestClassifier, | |
RBFSampler, | |
LDA, | |
GaussianNB, | |
LinearSVC, | |
SVC] | |
print '{:<20}\t{:}'.format('Estimator', 'Calls check_arrays?') | |
for estimator in estimators: | |
est = estimator() | |
try: | |
est.fit(X, Y) | |
except: | |
pass | |
print '{:<20}\t{:}'.format(estimator.__name__, sklearn.utils.check_arrays.called) | |
sklearn.utils.check_arrays.reset_mock() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment