Skip to content

n_jobs in GridSearchCV issue (again in 0.18.1) #9264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zeeraktalat opened this issue Jul 3, 2017 · 7 comments
Closed

n_jobs in GridSearchCV issue (again in 0.18.1) #9264

zeeraktalat opened this issue Jul 3, 2017 · 7 comments

Comments

@zeeraktalat
Copy link

zeeraktalat commented Jul 3, 2017

Hey, thanks for an awesome library!

There's a bit of an issue (seemingly the same as #6147) with GridSearchCV, which seems to be in 0.18.1 as well as having been present in previous versions. I get the issue when using GridSearchCV with the ElasticNet classifier:

vals = [10 ** i for i in range(0, -10, -1)] + list(np.arange(0.1, 0.999, 0.025))
parameters = {'l1_ratio': vals, 'alpha': vals}
elastic = ElasticNet(max_iter = 1000)
clf = GridSearchCV(elastic, param_grid = parameters, n_jobs = 8, scoring = 'accuracy', cv = 10)
clf.fit(X_train, y_train)

Actual Results

multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/_parallel_backends.py", line 344, in __call__
    return self.func(*args, **kwargs)
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py", line 131, in __call__
    return [func(*args, **kwargs) for func, args, kwargs in self.items]
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py", line 131, in <listcomp>
    return [func(*args, **kwargs) for func, args, kwargs in self.items]
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py", line 260, in _fit_and_score
    test_score = _score(estimator, X_test, y_test, scorer)
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py", line 288, in _score
    score = scorer(estimator, X_test, y_test)
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/scorer.py", line 98, in __call__
    **self._kwargs)
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py", line 172, in accuracy_score
    y_type, y_true, y_pred = _check_targets(y_true, y_pred)
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py", line 82, in _check_targets
    "".format(type_true, type_pred))
ValueError: Can't handle mix of binary and continuous

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zeerak/anaconda3/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/_parallel_backends.py", line 353, in __call__
    raise TransportableException(text, e_type)
sklearn.externals.joblib.my_exceptions.TransportableException: TransportableException
___________________________________________________________________________
ValueError                                         Mon Jul  3 02:20:59 2017
PID: 22695                 Python 3.6.0: /home/zeerak/anaconda3/bin/python3
...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in __call__(self=<sklearn.externals.joblib.parallel.BatchedCalls object>)
    126     def __init__(self, iterator_slice):
    127         self.items = list(iterator_slice)
    128         self._size = len(self.items)
    129
    130     def __call__(self):
--> 131         return [func(*args, **kwargs) for func, args, kwargs in self.items]
        self.items = [(<function _fit_and_score>, (ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], make_scorer(accuracy_score), array([ 530,  531,  532, ..., 5292, 5293, 5294]), array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), 0, {'alpha': 1, 'l1_ratio': 1}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True})]
    132
    133     def __len__(self):
    134         return self._size
    135

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
    126     def __init__(self, iterator_slice):
    127         self.items = list(iterator_slice)
    128         self._size = len(self.items)
    129
    130     def __call__(self):
--> 131         return [func(*args, **kwargs) for func, args, kwargs in self.items]
        func = <function _fit_and_score>
        args = (ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], make_scorer(accuracy_score), array([ 530,  531,  532, ..., 5292, 5293, 5294]), array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), 0, {'alpha': 1, 'l1_ratio': 1})
        kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True}
    132
    133     def __len__(self):
    134         return self._size
    135

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _fit_and_score(estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X=<5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, y=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], scorer=make_scorer(accuracy_score), train=array([ 530,  531,  532, ..., 5292, 5293, 5294]), test=array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), verbose=0, parameters={'alpha': 1, 'l1_ratio': 1}, fit_params={}, return_train_score=True, return_parameters=True, return_n_test_samples=True, return_times=True, error_score='raise')
    255                              " numeric value. (Hint: if using 'raise', please"
    256                              " make sure that it has been spelled correctly.)")
    257
    258     else:
    259         fit_time = time.time() - start_time
--> 260         test_score = _score(estimator, X_test, y_test, scorer)
        test_score = undefined
        estimator = ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False)
        X_test = <530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>
        y_test = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        scorer = make_scorer(accuracy_score)
    261         score_time = time.time() - start_time - fit_time
    262         if return_train_score:
    263             train_score = _score(estimator, X_train, y_train, scorer)
    264

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _score(estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X_test=<530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>, y_test=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], scorer=make_scorer(accuracy_score))
    283 def _score(estimator, X_test, y_test, scorer):
    284     """Compute the score of an estimator on a given test set."""
    285     if y_test is None:
    286         score = scorer(estimator, X_test)
    287     else:
--> 288         score = scorer(estimator, X_test, y_test)
        score = undefined
        scorer = make_scorer(accuracy_score)
        estimator = ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False)
        X_test = <530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>
        y_test = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
    289     if hasattr(score, 'item'):
    290         try:
    291             # e.g. unwrap memmapped scalars
    292             score = score.item()

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/scorer.py in __call__(self=make_scorer(accuracy_score), estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X=<530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>, y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], sample_weight=None)
     93             return self._sign * self._score_func(y_true, y_pred,
     94                                                  sample_weight=sample_weight,
     95                                                  **self._kwargs)
     96         else:
     97             return self._sign * self._score_func(y_true, y_pred,
---> 98                                                  **self._kwargs)
        self._kwargs = {}
     99
    100
    101 class _ProbaScorer(_BaseScorer):
    102     def __call__(self, clf, X, y, sample_weight=None):

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py in accuracy_score(y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], y_pred=array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042]), normalize=True, sample_weight=None)
    167     >>> accuracy_score(np.array([[0, 1], [1, 1]]), np.ones((2, 2)))
    168     0.5
    169     """
    170
    171     # Compute accuracy for each possible representation
--> 172     y_type, y_true, y_pred = _check_targets(y_true, y_pred)
        y_type = undefined
        y_true = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        y_pred = array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042])
    173     if y_type.startswith('multilabel'):
    174         differing_labels = count_nonzero(y_true - y_pred, axis=1)
    175         score = differing_labels == 0
    176     else:

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py in _check_targets(y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], y_pred=array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042]))
     77     if y_type == set(["binary", "multiclass"]):
     78         y_type = set(["multiclass"])
     79
     80     if len(y_type) > 1:
     81         raise ValueError("Can't handle mix of {0} and {1}"
---> 82                          "".format(type_true, type_pred))
        type_true = 'binary'
        type_pred = 'continuous'
     83
     84     # We can't have more than one value on y_type => The set is no more needed
     85     y_type = y_type.pop()
     86

ValueError: Can't handle mix of binary and continuous
___________________________________________________________________________
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py", line 682, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File "/home/zeerak/anaconda3/lib/python3.6/multiprocessing/pool.py", line 608, in get
    raise self._value
sklearn.externals.joblib.my_exceptions.TransportableException: TransportableException
___________________________________________________________________________
ValueError                                         Mon Jul  3 02:20:59 2017
PID: 22695                 Python 3.6.0: /home/zeerak/anaconda3/bin/python3
...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in __call__(self=<sklearn.externals.joblib.parallel.BatchedCalls object>)
    126     def __init__(self, iterator_slice):
    127         self.items = list(iterator_slice)
    128         self._size = len(self.items)
    129
    130     def __call__(self):
--> 131         return [func(*args, **kwargs) for func, args, kwargs in self.items]
        self.items = [(<function _fit_and_score>, (ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], make_scorer(accuracy_score), array([ 530,  531,  532, ..., 5292, 5293, 5294]), array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), 0, {'alpha': 1, 'l1_ratio': 1}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True})]
    132
    133     def __len__(self):
    134         return self._size
    135

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
    126     def __init__(self, iterator_slice):
    127         self.items = list(iterator_slice)
    128         self._size = len(self.items)
    129
    130     def __call__(self):
--> 131         return [func(*args, **kwargs) for func, args, kwargs in self.items]
        func = <function _fit_and_score>
        args = (ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], make_scorer(accuracy_score), array([ 530,  531,  532, ..., 5292, 5293, 5294]), array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), 0, {'alpha': 1, 'l1_ratio': 1})
        kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True}
    132
    133     def __len__(self):
    134         return self._size
    135

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _fit_and_score(estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X=<5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, y=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], scorer=make_scorer(accuracy_score), train=array([ 530,  531,  532, ..., 5292, 5293, 5294]), test=array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), verbose=0, parameters={'alpha': 1, 'l1_ratio': 1}, fit_params={}, return_train_score=True, return_parameters=True, return_n_test_samples=True, return_times=True, error_score='raise')
    255                              " numeric value. (Hint: if using 'raise', please"
    256                              " make sure that it has been spelled correctly.)")
    257
    258     else:
    259         fit_time = time.time() - start_time
--> 260         test_score = _score(estimator, X_test, y_test, scorer)
        test_score = undefined
        estimator = ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False)
        X_test = <530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>
        y_test = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        scorer = make_scorer(accuracy_score)
    261         score_time = time.time() - start_time - fit_time
    262         if return_train_score:
    263             train_score = _score(estimator, X_train, y_train, scorer)
    264

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _score(estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X_test=<530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>, y_test=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], scorer=make_scorer(accuracy_score))
    283 def _score(estimator, X_test, y_test, scorer):
    284     """Compute the score of an estimator on a given test set."""
    285     if y_test is None:
    286         score = scorer(estimator, X_test)
    287     else:
--> 288         score = scorer(estimator, X_test, y_test)
        score = undefined
        scorer = make_scorer(accuracy_score)
        estimator = ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False)
        X_test = <530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>
        y_test = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
    289     if hasattr(score, 'item'):
    290         try:
    291             # e.g. unwrap memmapped scalars
    292             score = score.item()

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/scorer.py in __call__(self=make_scorer(accuracy_score), estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X=<530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>, y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], sample_weight=None)
     93             return self._sign * self._score_func(y_true, y_pred,
     94                                                  sample_weight=sample_weight,
     95                                                  **self._kwargs)
     96         else:
     97             return self._sign * self._score_func(y_true, y_pred,
---> 98                                                  **self._kwargs)
        self._kwargs = {}
     99
    100
    101 class _ProbaScorer(_BaseScorer):
    102     def __call__(self, clf, X, y, sample_weight=None):

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py in accuracy_score(y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], y_pred=array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042]), normalize=True, sample_weight=None)
    167     >>> accuracy_score(np.array([[0, 1], [1, 1]]), np.ones((2, 2)))
    168     0.5
    169     """
    170
    171     # Compute accuracy for each possible representation
--> 172     y_type, y_true, y_pred = _check_targets(y_true, y_pred)
        y_type = undefined
        y_true = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        y_pred = array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042])
    173     if y_type.startswith('multilabel'):
    174         differing_labels = count_nonzero(y_true - y_pred, axis=1)
    175         score = differing_labels == 0
    176     else:

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py in _check_targets(y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], y_pred=array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042]))
     77     if y_type == set(["binary", "multiclass"]):
     78         y_type = set(["multiclass"])
     79
     80     if len(y_type) > 1:
     81         raise ValueError("Can't handle mix of {0} and {1}"
---> 82                          "".format(type_true, type_pred))
        type_true = 'binary'
        type_pred = 'continuous'
     83
     84     # We can't have more than one value on y_type => The set is no more needed
     85     y_type = y_type.pop()
     86

ValueError: Can't handle mix of binary and continuous
___________________________________________________________________________

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run.py", line 333, in <module>
    runner(args)
  File "run.py", line 283, in runner
    feats.run_gridsearch_elastic(X_train, X_test, Y_train, Y_test)
  File "/home/zeerak/Projects/repos/gender_spectrum/features.py", line 216, in run_gridsearch_elastic
    clf.fit(X_train, y_train)
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 945, in fit
    return self._fit(X, y, groups, ParameterGrid(self.param_grid))
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 564, in _fit
    for parameters in parameter_iterable
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py", line 768, in __call__
    self.retrieve()
  File "/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py", line 719, in retrieve
    raise exception
sklearn.externals.joblib.my_exceptions.JoblibValueError: JoblibValueError
___________________________________________________________________________
Multiprocessing exception:
...........................................................................
/home/zeerak/Projects/repos/gender_spectrum/run.py in <module>()
    328     parser.add_argument('--probs'     , action = 'store_true', help = argparse.SUPPRESS)
    329     parser.add_argument('--sgdparams' , nargs = 2            , help = argparse.SUPPRESS)
    330
    331     args = parser.parse_args()
    332
--> 333     runner(args)
    334
    335
    336
    337

...........................................................................
/home/zeerak/Projects/repos/gender_spectrum/run.py in runner(args=Namespace(data=None, feats=['unigram-counts'], h...dparams=None, test=None, user=True, workers=None))
    278             feats.run_gridsearch_sgd(X_train, X_test, Y_train, Y_test)
    279             # preds, weights, intercept = feats.run_sgd(X_train, X_test, Y_train, Y_test)
    280
    281         elif args.method == 'Elastic':
    282             print('Run Elastic Net...', file=sys.stdout)
--> 283             feats.run_gridsearch_elastic(X_train, X_test, Y_train, Y_test)
        X_train = <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>
        X_test = <1324x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>
        Y_train = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        Y_test = ['1', '0', '1', '1', '1', '1', '0', '1', '0', '0', '0', '1', '1', '0', '1', '1', '0', '0', '0', '0', ...]
    284             # preds, weights, intercept = feats.run_sgd(X_train, X_test, Y_train, Y_test)
    285
    286
    287 if __name__ == "__main__":

...........................................................................
/home/zeerak/Projects/repos/gender_spectrum/features.py in run_gridsearch_elastic(X_train=<5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, X_test=<1324x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, y_train=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], y_test=['1', '0', '1', '1', '1', '1', '0', '1', '0', '0', '0', '1', '1', '0', '1', '1', '0', '0', '0', '0', ...])
    211 def run_gridsearch_elastic(X_train, X_test, y_train, y_test):
    212     vals = [10 ** i for i in range(0, -10, -1)] + list(np.arange(0.1, 0.999, 0.015))
    213     parameters = {'l1_ratio': vals, 'alpha': vals}
    214     elastic = ElasticNet(max_iter = 1000)
    215     clf = GridSearchCV(elastic, param_grid = parameters, n_jobs = 8, scoring = 'accuracy', cv = 10)
--> 216     clf.fit(X_train, y_train)
        clf.fit = <bound method GridSearchCV.fit of GridSearchCV(c...core=True,
       scoring='accuracy', verbose=0)>
        X_train = <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>
        y_train = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
    217     preds = clf.predict(X_test)
    218     print(clf.best_estimator_, clf.best_score_, clf.best_params_)
    219     print("Accuracy: %s" % accuracy_score(y_test, preds))
    220

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_search.py in fit(self=GridSearchCV(cv=10, error_score='raise',
       ...score=True,
       scoring='accuracy', verbose=0), X=<5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, y=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], groups=None)
    940
    941         groups : array-like, with shape (n_samples,), optional
    942             Group labels for the samples used while splitting the dataset into
    943             train/test set.
    944         """
--> 945         return self._fit(X, y, groups, ParameterGrid(self.param_grid))
        self._fit = <bound method BaseSearchCV._fit of GridSearchCV(...core=True,
       scoring='accuracy', verbose=0)>
        X = <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>
        y = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        groups = None
        self.param_grid = {'alpha': [1, 0.1, 0.01, 0.001, 0.0001, 1e-05, 1e-06, 1e-07, 1e-08, 1e-09, 0.10000000000000001, 0.115, 0.13, 0.14500000000000002, 0.16, 0.17499999999999999, 0.19, 0.20500000000000002, 0.22, 0.23500000000000001, ...], 'l1_ratio': [1, 0.1, 0.01, 0.001, 0.0001, 1e-05, 1e-06, 1e-07, 1e-08, 1e-09, 0.10000000000000001, 0.115, 0.13, 0.14500000000000002, 0.16, 0.17499999999999999, 0.19, 0.20500000000000002, 0.22, 0.23500000000000001, ...]}
    946
    947
    948 class RandomizedSearchCV(BaseSearchCV):
    949     """Randomized search on hyper parameters.

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_search.py in _fit(self=GridSearchCV(cv=10, error_score='raise',
       ...score=True,
       scoring='accuracy', verbose=0), X=<5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, y=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], groups=None, parameter_iterable=<sklearn.model_selection._search.ParameterGrid object>)
    559                                   fit_params=self.fit_params,
    560                                   return_train_score=self.return_train_score,
    561                                   return_n_test_samples=True,
    562                                   return_times=True, return_parameters=True,
    563                                   error_score=self.error_score)
--> 564           for parameters in parameter_iterable
        parameters = undefined
        parameter_iterable = <sklearn.model_selection._search.ParameterGrid object>
    565           for train, test in cv_iter)
    566
    567         # if one choose to see train score, "out" will contain train score info
    568         if self.return_train_score:

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in __call__(self=Parallel(n_jobs=8), iterable=<generator object BaseSearchCV._fit.<locals>.<genexpr>>)
    763             if pre_dispatch == "all" or n_jobs == 1:
    764                 # The iterable was consumed all at once by the above for loop.
    765                 # No need to wait for async callbacks to trigger to
    766                 # consumption.
    767                 self._iterating = False
--> 768             self.retrieve()
        self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=8)>
    769             # Make sure that we get a last message telling us we are done
    770             elapsed_time = time.time() - self._start_time
    771             self._print('Done %3i out of %3i | elapsed: %s finished',
    772                         (len(self._output), len(self._output),

Sub-process traceback:

ValueError                                         Mon Jul  3 02:20:59 2017
PID: 22695                 Python 3.6.0: /home/zeerak/anaconda3/bin/python3
...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in __call__(self=<sklearn.externals.joblib.parallel.BatchedCalls object>)
    126     def __init__(self, iterator_slice):
    127         self.items = list(iterator_slice)
    128         self._size = len(self.items)
    129
    130     def __call__(self):
--> 131         return [func(*args, **kwargs) for func, args, kwargs in self.items]
        self.items = [(<function _fit_and_score>, (ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], make_scorer(accuracy_score), array([ 530,  531,  532, ..., 5292, 5293, 5294]), array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), 0, {'alpha': 1, 'l1_ratio': 1}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True})]
    132
    133     def __len__(self):
    134         return self._size
    135

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/parallel.py in <listcomp>(.0=<list_iterator object>)
    126     def __init__(self, iterator_slice):
    127         self.items = list(iterator_slice)
    128         self._size = len(self.items)
    129
    130     def __call__(self):
--> 131         return [func(*args, **kwargs) for func, args, kwargs in self.items]
        func = <function _fit_and_score>
        args = (ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), <5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], make_scorer(accuracy_score), array([ 530,  531,  532, ..., 5292, 5293, 5294]), array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), 0, {'alpha': 1, 'l1_ratio': 1})
        kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True}
    132
    133     def __len__(self):
    134         return self._size
    135

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _fit_and_score(estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X=<5295x86231 sparse matrix of type '<class 'numpy... stored elements in Compressed Sparse Row format>, y=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], scorer=make_scorer(accuracy_score), train=array([ 530,  531,  532, ..., 5292, 5293, 5294]), test=array([  0,   1,   2,   3,   4,   5,   6,   7,  ...20, 521, 522, 523, 524, 525, 526, 527, 528, 529]), verbose=0, parameters={'alpha': 1, 'l1_ratio': 1}, fit_params={}, return_train_score=True, return_parameters=True, return_n_test_samples=True, return_times=True, error_score='raise')
    255                              " numeric value. (Hint: if using 'raise', please"
    256                              " make sure that it has been spelled correctly.)")
    257
    258     else:
    259         fit_time = time.time() - start_time
--> 260         test_score = _score(estimator, X_test, y_test, scorer)
        test_score = undefined
        estimator = ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False)
        X_test = <530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>
        y_test = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        scorer = make_scorer(accuracy_score)
    261         score_time = time.time() - start_time - fit_time
    262         if return_train_score:
    263             train_score = _score(estimator, X_train, y_train, scorer)
    264

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _score(estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X_test=<530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>, y_test=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], scorer=make_scorer(accuracy_score))
    283 def _score(estimator, X_test, y_test, scorer):
    284     """Compute the score of an estimator on a given test set."""
    285     if y_test is None:
    286         score = scorer(estimator, X_test)
    287     else:
--> 288         score = scorer(estimator, X_test, y_test)
        score = undefined
        scorer = make_scorer(accuracy_score)
        estimator = ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False)
        X_test = <530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>
        y_test = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
    289     if hasattr(score, 'item'):
    290         try:
    291             # e.g. unwrap memmapped scalars
    292             score = score.item()

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/scorer.py in __call__(self=make_scorer(accuracy_score), estimator=ElasticNet(alpha=1, copy_X=True, fit_intercept=T...selection='cyclic', tol=0.0001, warm_start=False), X=<530x86231 sparse matrix of type '<class 'numpy.... stored elements in Compressed Sparse Row format>, y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], sample_weight=None)
     93             return self._sign * self._score_func(y_true, y_pred,
     94                                                  sample_weight=sample_weight,
     95                                                  **self._kwargs)
     96         else:
     97             return self._sign * self._score_func(y_true, y_pred,
---> 98                                                  **self._kwargs)
        self._kwargs = {}
     99
    100
    101 class _ProbaScorer(_BaseScorer):
    102     def __call__(self, clf, X, y, sample_weight=None):

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py in accuracy_score(y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], y_pred=array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042]), normalize=True, sample_weight=None)
    167     >>> accuracy_score(np.array([[0, 1], [1, 1]]), np.ones((2, 2)))
    168     0.5
    169     """
    170
    171     # Compute accuracy for each possible representation
--> 172     y_type, y_true, y_pred = _check_targets(y_true, y_pred)
        y_type = undefined
        y_true = ['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...]
        y_pred = array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042])
    173     if y_type.startswith('multilabel'):
    174         differing_labels = count_nonzero(y_true - y_pred, axis=1)
    175         score = differing_labels == 0
    176     else:

...........................................................................
/home/zeerak/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py in _check_targets(y_true=['0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1', '1', '1', '0', '1', '0', '1', '1', '0', ...], y_pred=array([ 0.5320042,  0.5320042,  0.5320042,  0.53...  0.5320042,  0.5320042,  0.5320042,  0.5320042]))
     77     if y_type == set(["binary", "multiclass"]):
     78         y_type = set(["multiclass"])
     79
     80     if len(y_type) > 1:
     81         raise ValueError("Can't handle mix of {0} and {1}"
---> 82                          "".format(type_true, type_pred))
        type_true = 'binary'
        type_pred = 'continuous'
     83
     84     # We can't have more than one value on y_type => The set is no more needed
     85     y_type = y_type.pop()
     86

ValueError: Can't handle mix of binary and continuous
___________________________________________________________________________

Versions

platform.platform(): Linux-4.2.3-300.fc23.x86_64-x86_64-with-fedora-25-Twenty_Five
sys.version: Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
numpy.version: NumPy 1.11.3
scipy.version: SciPy 0.18.1
sklearn.version: Scikit-Learn 0.18.1

@GaelVaroquaux
Copy link
Member

GaelVaroquaux commented Jul 3, 2017 via email

@jnothman
Copy link
Member

jnothman commented Jul 3, 2017 via email

@zeeraktalat
Copy link
Author

@GaelVaroquaux Yup, it only occurs with n_jobs > 1. Fixing the errors with the invalid y does not change it. However, the scoring fixed it. Had missed that I hadn't updated the scoring.

@jnothman Thanks for that, this was the issue! Not entirely sure why this brought out the issue though.

@jnothman
Copy link
Member

jnothman commented Jul 4, 2017 via email

@ujwal107
Copy link

ujwal107 commented Oct 3, 2018

fitted_models = {}

Loop through model pipelines, tuning each one and saving it to fitted_models

for name, pipeline in pipelines.items():
# Create cross-validation object from pipeline and hyperparameters
model = GridSearchCV(pipeline, hyperparameters[name], cv = 10, n_jobs=-1)

# Fit model on X_train, y_train
model.fit(X_train, y_train)

# Store model in fitted_models[name] 
fitted_models[name] = model

# Print '{name} has been fitted'
print('{0} has been fitted'.format(name))

It gives following error:
RemoteTraceback Traceback (most recent call last)
RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib_parallel_backends.py", line 350, in call
return self.func(*args, **kwargs)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py", line 131, in call
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py", line 131, in
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\model_selection_validation.py", line 458, in _fit_and_score
estimator.fit(X_train, y_train, **fit_params)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py", line 248, in fit
Xt, fit_params = self._fit(X, y, **fit_params)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py", line 213, in _fit
**fit_params_steps[name])
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\memory.py", line 362, in call
return self.func(*args, **kwargs)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py", line 581, in _fit_transform_one
res = transformer.fit_transform(X, y, **fit_params)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\base.py", line 520, in fit_transform
return self.fit(X, y, **fit_params).transform(X)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py", line 590, in fit
return self.partial_fit(X, y)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py", line 612, in partial_fit
warn_on_dtype=True, estimator=self, dtype=FLOAT_DTYPES)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 453, in check_array
_assert_all_finite(array)
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 44, in _assert_all_finite
" or a value too large for %r." % X.dtype)
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\HP\Anaconda3\lib\multiprocessing\pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib_parallel_backends.py", line 359, in call
raise TransportableException(text, e_type)
sklearn.externals.joblib.my_exceptions.TransportableException: TransportableException


ValueError Wed Oct 3 16:16:44 2018
PID: 7136 Python 3.6.5: C:\Users\HP\Anaconda3\python.exe
...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in call(self=<sklearn.externals.joblib.parallel.BatchedCalls object>)
126 def init(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(, (Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), Token Number AGE ... ... 1

[97 rows x 449 columns], 54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, {'score': }, array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), 0, {'logisticregression__C': 0.001}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': False, 'return_times': True, 'return_train_score': 'warn'})]
132
133 def len(self):
134 return self._size
135

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in (.0=<list_iterator object>)
126 def init(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func =
args = (Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), Token Number AGE ... ... 1

[97 rows x 449 columns], 54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, {'score': }, array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), 0, {'logisticregression__C': 0.001})
kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': False, 'return_times': True, 'return_train_score': 'warn'}
132
133 def len(self):
134 return self._size
135

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\model_selection_validation.py in _fit_and_score(estimator=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[97 rows x 449 columns], y=54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, scorer={'score': }, train=array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), test=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), verbose=0, parameters={'logisticregression__C': 0.001}, fit_params={}, return_train_score='warn', return_parameters=False, return_n_test_samples=True, return_times=True, error_score='raise')
453
454 try:
455 if y_train is None:
456 estimator.fit(X_train, **fit_params)
457 else:
--> 458 estimator.fit(X_train, y_train, **fit_params)
estimator.fit = <bound method Pipeline.fit of Pipeline(memory=No....0001,
verbose=0, warm_start=False))])>
X_train = Token Number AGE ... ... 1

[86 rows x 449 columns]
y_train = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params = {}
459
460 except Exception as e:
461 # Note fit time as time until error
462 fit_time = time.time() - start_time

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in fit(self=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
243 Returns
244 -------
245 self : Pipeline
246 This estimator
247 """
--> 248 Xt, fit_params = self._fit(X, y, **fit_params)
Xt = undefined
fit_params = {}
self._fit = <bound method Pipeline._fit of Pipeline(memory=N....0001,
verbose=0, warm_start=False))])>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
249 if self._final_estimator is not None:
250 self._final_estimator.fit(Xt, y, **fit_params)
251 return self
252

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit(self=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
208 else:
209 cloned_transformer = clone(transformer)
210 # Fit or load from cache the current transfomer
211 Xt, fitted_transformer = fit_transform_one_cached(
212 cloned_transformer, None, Xt, y,
--> 213 **fit_params_steps[name])
fit_params_steps = {'logisticregression': {}, 'standardscaler': {}}
name = 'standardscaler'
214 # Replace the transformer of the step with the fitted
215 # transformer. This is necessary when loading the transformer
216 # from the cache.
217 self.steps[step_idx] = (name, fitted_transformer)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\memory.py in call(self=NotMemorizedFunc(func=<function _fit_transform_one at 0x000001FC877EC8C8>), *args=(StandardScaler(copy=True, with_mean=True, with_std=True), None, Token Number AGE ... ... 1

[86 rows x 449 columns], 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64), **kwargs={})
357 # Should be a light as possible (for speed)
358 def init(self, func):
359 self.func = func
360
361 def call(self, *args, **kwargs):
--> 362 return self.func(*args, **kwargs)
self.func =
args = (StandardScaler(copy=True, with_mean=True, with_std=True), None, Token Number AGE ... ... 1

[86 rows x 449 columns], 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
kwargs = {}
363
364 def call_and_shelve(self, *args, **kwargs):
365 return NotMemorizedResult(self.func(*args, **kwargs))
366

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit_transform_one(transformer=StandardScaler(copy=True, with_mean=True, with_std=True), weight=None, X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
576
577
578 def _fit_transform_one(transformer, weight, X, y,
579 **fit_params):
580 if hasattr(transformer, 'fit_transform'):
--> 581 res = transformer.fit_transform(X, y, **fit_params)
res = undefined
transformer.fit_transform = <bound method TransformerMixin.fit_transform of ...Scaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params = {}
582 else:
583 res = transformer.fit(X, y, **fit_params).transform(X)
584 # if we have a weight for this transformer, multiply output
585 if weight is None:

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\base.py in fit_transform(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
515 if y is None:
516 # fit method of arity 1 (unsupervised transformation)
517 return self.fit(X, **fit_params).transform(X)
518 else:
519 # fit method of arity 2 (supervised transformation)
--> 520 return self.fit(X, y, **fit_params).transform(X)
self.fit = <bound method StandardScaler.fit of StandardScaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params.transform = undefined
521
522
523 class DensityMixin(object):
524 """Mixin class for all density estimators in scikit-learn."""

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py in fit(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
585 y : Passthrough for Pipeline compatibility.
586 """
587
588 # Reset internal state before fitting
589 self._reset()
--> 590 return self.partial_fit(X, y)
self.partial_fit = <bound method StandardScaler.partial_fit of Stan...Scaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
591
592 def partial_fit(self, X, y=None):
593 """Online computation of mean and std on X for later scaling.
594 All of X is processed as a single batch. This is intended for cases

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py in partial_fit(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
607 used for later scaling along the features axis.
608
609 y : Passthrough for Pipeline compatibility.
610 """
611 X = check_array(X, accept_sparse=('csr', 'csc'), copy=self.copy,
--> 612 warn_on_dtype=True, estimator=self, dtype=FLOAT_DTYPES)
self = StandardScaler(copy=True, with_mean=True, with_std=True)
613
614 # Even in the case of with_mean=False, we update the mean anyway
615 # This is needed for the incremental computation of the var
616 # See incr_mean_variance_axis and _incremental_mean_variance_axis

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_array(array=array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]]), accept_sparse=('csr', 'csc'), dtype=<class 'numpy.float64'>, order=None, copy=True, force_all_finite=True, ensure_2d=True, allow_nd=False, ensure_min_samples=1, ensure_min_features=1, warn_on_dtype=True, estimator=StandardScaler(copy=True, with_mean=True, with_std=True))
448 array = array.astype(np.float64)
449 if not allow_nd and array.ndim >= 3:
450 raise ValueError("Found array with dim %d. %s expected <= 2."
451 % (array.ndim, estimator_name))
452 if force_all_finite:
--> 453 _assert_all_finite(array)
array = array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]])
454
455 shape_repr = _shape_repr(array.shape)
456 if ensure_min_samples > 0:
457 n_samples = _num_samples(array)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py in _assert_all_finite(X=array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]]))
39 # everything is finite; fall back to O(n) space np.isfinite to prevent
40 # false positives from overflow in sum method.
41 if (X.dtype.char in np.typecodes['AllFloat'] and not np.isfinite(X.sum())
42 and not np.isfinite(X).all()):
43 raise ValueError("Input contains NaN, infinity"
---> 44 " or a value too large for %r." % X.dtype)
X.dtype = dtype('float64')
45
46
47 def assert_all_finite(X):
48 """Throw a ValueError if X contains NaN or infinity.

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').


"""

The above exception was the direct cause of the following exception:

TransportableException Traceback (most recent call last)
~\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in retrieve(self)
698 if getattr(self._backend, 'supports_timeout', False):
--> 699 self._output.extend(job.get(timeout=self.timeout))
700 else:

~\Anaconda3\lib\multiprocessing\pool.py in get(self, timeout)
643 else:
--> 644 raise self._value
645

TransportableException: TransportableException


ValueError Wed Oct 3 16:16:44 2018
PID: 7136 Python 3.6.5: C:\Users\HP\Anaconda3\python.exe
...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in call(self=<sklearn.externals.joblib.parallel.BatchedCalls object>)
126 def init(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(, (Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), Token Number AGE ... ... 1

[97 rows x 449 columns], 54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, {'score': }, array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), 0, {'logisticregression__C': 0.001}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': False, 'return_times': True, 'return_train_score': 'warn'})]
132
133 def len(self):
134 return self._size
135

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in (.0=<list_iterator object>)
126 def init(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func =
args = (Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), Token Number AGE ... ... 1

[97 rows x 449 columns], 54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, {'score': }, array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), 0, {'logisticregression__C': 0.001})
kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': False, 'return_times': True, 'return_train_score': 'warn'}
132
133 def len(self):
134 return self._size
135

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\model_selection_validation.py in _fit_and_score(estimator=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[97 rows x 449 columns], y=54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, scorer={'score': }, train=array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), test=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), verbose=0, parameters={'logisticregression__C': 0.001}, fit_params={}, return_train_score='warn', return_parameters=False, return_n_test_samples=True, return_times=True, error_score='raise')
453
454 try:
455 if y_train is None:
456 estimator.fit(X_train, **fit_params)
457 else:
--> 458 estimator.fit(X_train, y_train, **fit_params)
estimator.fit = <bound method Pipeline.fit of Pipeline(memory=No....0001,
verbose=0, warm_start=False))])>
X_train = Token Number AGE ... ... 1

[86 rows x 449 columns]
y_train = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params = {}
459
460 except Exception as e:
461 # Note fit time as time until error
462 fit_time = time.time() - start_time

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in fit(self=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
243 Returns
244 -------
245 self : Pipeline
246 This estimator
247 """
--> 248 Xt, fit_params = self._fit(X, y, **fit_params)
Xt = undefined
fit_params = {}
self._fit = <bound method Pipeline._fit of Pipeline(memory=N....0001,
verbose=0, warm_start=False))])>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
249 if self._final_estimator is not None:
250 self._final_estimator.fit(Xt, y, **fit_params)
251 return self
252

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit(self=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
208 else:
209 cloned_transformer = clone(transformer)
210 # Fit or load from cache the current transfomer
211 Xt, fitted_transformer = fit_transform_one_cached(
212 cloned_transformer, None, Xt, y,
--> 213 **fit_params_steps[name])
fit_params_steps = {'logisticregression': {}, 'standardscaler': {}}
name = 'standardscaler'
214 # Replace the transformer of the step with the fitted
215 # transformer. This is necessary when loading the transformer
216 # from the cache.
217 self.steps[step_idx] = (name, fitted_transformer)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\memory.py in call(self=NotMemorizedFunc(func=<function _fit_transform_one at 0x000001FC877EC8C8>), *args=(StandardScaler(copy=True, with_mean=True, with_std=True), None, Token Number AGE ... ... 1

[86 rows x 449 columns], 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64), **kwargs={})
357 # Should be a light as possible (for speed)
358 def init(self, func):
359 self.func = func
360
361 def call(self, *args, **kwargs):
--> 362 return self.func(*args, **kwargs)
self.func =
args = (StandardScaler(copy=True, with_mean=True, with_std=True), None, Token Number AGE ... ... 1

[86 rows x 449 columns], 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
kwargs = {}
363
364 def call_and_shelve(self, *args, **kwargs):
365 return NotMemorizedResult(self.func(*args, **kwargs))
366

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit_transform_one(transformer=StandardScaler(copy=True, with_mean=True, with_std=True), weight=None, X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
576
577
578 def _fit_transform_one(transformer, weight, X, y,
579 **fit_params):
580 if hasattr(transformer, 'fit_transform'):
--> 581 res = transformer.fit_transform(X, y, **fit_params)
res = undefined
transformer.fit_transform = <bound method TransformerMixin.fit_transform of ...Scaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params = {}
582 else:
583 res = transformer.fit(X, y, **fit_params).transform(X)
584 # if we have a weight for this transformer, multiply output
585 if weight is None:

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\base.py in fit_transform(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
515 if y is None:
516 # fit method of arity 1 (unsupervised transformation)
517 return self.fit(X, **fit_params).transform(X)
518 else:
519 # fit method of arity 2 (supervised transformation)
--> 520 return self.fit(X, y, **fit_params).transform(X)
self.fit = <bound method StandardScaler.fit of StandardScaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params.transform = undefined
521
522
523 class DensityMixin(object):
524 """Mixin class for all density estimators in scikit-learn."""

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py in fit(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
585 y : Passthrough for Pipeline compatibility.
586 """
587
588 # Reset internal state before fitting
589 self._reset()
--> 590 return self.partial_fit(X, y)
self.partial_fit = <bound method StandardScaler.partial_fit of Stan...Scaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
591
592 def partial_fit(self, X, y=None):
593 """Online computation of mean and std on X for later scaling.
594 All of X is processed as a single batch. This is intended for cases

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py in partial_fit(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
607 used for later scaling along the features axis.
608
609 y : Passthrough for Pipeline compatibility.
610 """
611 X = check_array(X, accept_sparse=('csr', 'csc'), copy=self.copy,
--> 612 warn_on_dtype=True, estimator=self, dtype=FLOAT_DTYPES)
self = StandardScaler(copy=True, with_mean=True, with_std=True)
613
614 # Even in the case of with_mean=False, we update the mean anyway
615 # This is needed for the incremental computation of the var
616 # See incr_mean_variance_axis and _incremental_mean_variance_axis

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_array(array=array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]]), accept_sparse=('csr', 'csc'), dtype=<class 'numpy.float64'>, order=None, copy=True, force_all_finite=True, ensure_2d=True, allow_nd=False, ensure_min_samples=1, ensure_min_features=1, warn_on_dtype=True, estimator=StandardScaler(copy=True, with_mean=True, with_std=True))
448 array = array.astype(np.float64)
449 if not allow_nd and array.ndim >= 3:
450 raise ValueError("Found array with dim %d. %s expected <= 2."
451 % (array.ndim, estimator_name))
452 if force_all_finite:
--> 453 _assert_all_finite(array)
array = array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]])
454
455 shape_repr = _shape_repr(array.shape)
456 if ensure_min_samples > 0:
457 n_samples = _num_samples(array)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py in _assert_all_finite(X=array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]]))
39 # everything is finite; fall back to O(n) space np.isfinite to prevent
40 # false positives from overflow in sum method.
41 if (X.dtype.char in np.typecodes['AllFloat'] and not np.isfinite(X.sum())
42 and not np.isfinite(X).all()):
43 raise ValueError("Input contains NaN, infinity"
---> 44 " or a value too large for %r." % X.dtype)
X.dtype = dtype('float64')
45
46
47 def assert_all_finite(X):
48 """Throw a ValueError if X contains NaN or infinity.

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').


During handling of the above exception, another exception occurred:

JoblibValueError Traceback (most recent call last)
in ()
7
8 # Fit model on X_train, y_train
----> 9 model.fit(X_train, y_train)
10
11 # Store model in fitted_models[name]

~\Anaconda3\lib\site-packages\sklearn\model_selection_search.py in fit(self, X, y, groups, **fit_params)
637 error_score=self.error_score)
638 for parameters, (train, test) in product(candidate_params,
--> 639 cv.split(X, y, groups)))
640
641 # if one choose to see train score, "out" will contain train score info

~\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in call(self, iterable)
787 # consumption.
788 self._iterating = False
--> 789 self.retrieve()
790 # Make sure that we get a last message telling us we are done
791 elapsed_time = time.time() - self._start_time

~\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in retrieve(self)
738 exception = exception_type(report)
739
--> 740 raise exception
741
742 def call(self, iterable):

JoblibValueError: JoblibValueError


Multiprocessing exception:
...........................................................................
C:\Users\HP\Anaconda3\lib\runpy.py in _run_module_as_main(mod_name='ipykernel_launcher', alter_argv=1)
188 sys.exit(msg)
189 main_globals = sys.modules["main"].dict
190 if alter_argv:
191 sys.argv[0] = mod_spec.origin
192 return _run_code(code, main_globals, None,
--> 193 "main", mod_spec)
mod_spec = ModuleSpec(name='ipykernel_launcher', loader=<_f...nda3\lib\site-packages\ipykernel_launcher.py')
194
195 def run_module(mod_name, init_globals=None,
196 run_name=None, alter_sys=False):
197 """Execute a module's code without importing it

...........................................................................
C:\Users\HP\Anaconda3\lib\runpy.py in run_code(code=<code object at 0x0000020E99CFDD20, fil...lib\site-packages\ipykernel_launcher.py", line 5>, run_globals={'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'cached': r'C:\Users\HP\Anaconda3\lib\site-packages_pycache\ipykernel_launcher.cpython-36.pyc', 'doc': 'Entry point for launching an IPython kernel.\n\nTh...orts until\nafter removing the cwd from sys.path.\n', 'file': r'C:\Users\HP\Anaconda3\lib\site-packages\ipykernel_launcher.py', 'loader': <_frozen_importlib_external.SourceFileLoader object>, 'name': 'main', 'package': '', 'spec': ModuleSpec(name='ipykernel_launcher', loader=<_f...nda3\lib\site-packages\ipykernel_launcher.py'), 'app': <module 'ipykernel.kernelapp' from 'C:\Users\H...a3\lib\site-packages\ipykernel\kernelapp.py'>, ...}, init_globals=None, mod_name='main', mod_spec=ModuleSpec(name='ipykernel_launcher', loader=<f...nda3\lib\site-packages\ipykernel_launcher.py'), pkg_name='', script_name=None)
80 cached = cached,
81 doc = None,
82 loader = loader,
83 package = pkg_name,
84 spec = mod_spec)
---> 85 exec(code, run_globals)
code = <code object at 0x0000020E99CFDD20, fil...lib\site-packages\ipykernel_launcher.py", line 5>
run_globals = {'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'cached': r'C:\Users\HP\Anaconda3\lib\site-packages_pycache
\ipykernel_launcher.cpython-36.pyc', 'doc': 'Entry point for launching an IPython kernel.\n\nTh...orts until\nafter removing the cwd from sys.path.\n', 'file': r'C:\Users\HP\Anaconda3\lib\site-packages\ipykernel_launcher.py', 'loader': <_frozen_importlib_external.SourceFileLoader object>, 'name': 'main', 'package': '', 'spec': ModuleSpec(name='ipykernel_launcher', loader=<_f...nda3\lib\site-packages\ipykernel_launcher.py'), 'app': <module 'ipykernel.kernelapp' from 'C:\Users\H...a3\lib\site-packages\ipykernel\kernelapp.py'>, ...}
86 return run_globals
87
88 def _run_module_code(code, init_globals=None,
89 mod_name=None, mod_spec=None,

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\ipykernel_launcher.py in ()
11 # This is added back by InteractiveShellApp.init_path()
12 if sys.path[0] == '':
13 del sys.path[0]
14
15 from ipykernel import kernelapp as app
---> 16 app.launch_new_instance()

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\traitlets\config\application.py in launch_instance(cls=<class 'ipykernel.kernelapp.IPKernelApp'>, argv=None, **kwargs={})
653
654 If a global instance already exists, this reinitializes and starts it
655 """
656 app = cls.instance(**kwargs)
657 app.initialize(argv)
--> 658 app.start()
app.start = <bound method IPKernelApp.start of <ipykernel.kernelapp.IPKernelApp object>>
659
660 #-----------------------------------------------------------------------------
661 # utility functions, for convenience
662 #-----------------------------------------------------------------------------

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\ipykernel\kernelapp.py in start(self=<ipykernel.kernelapp.IPKernelApp object>)
481 if self.poller is not None:
482 self.poller.start()
483 self.kernel.start()
484 self.io_loop = ioloop.IOLoop.current()
485 try:
--> 486 self.io_loop.start()
self.io_loop.start = <bound method BaseAsyncIOLoop.start of <tornado.platform.asyncio.AsyncIOMainLoop object>>
487 except KeyboardInterrupt:
488 pass
489
490 launch_new_instance = IPKernelApp.launch_instance

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\tornado\platform\asyncio.py in start(self=<tornado.platform.asyncio.AsyncIOMainLoop object>)
122 except (RuntimeError, AssertionError):
123 old_loop = None
124 try:
125 self._setup_logging()
126 asyncio.set_event_loop(self.asyncio_loop)
--> 127 self.asyncio_loop.run_forever()
self.asyncio_loop.run_forever = <bound method BaseEventLoop.run_forever of <_Win...EventLoop running=True closed=False debug=False>>
128 finally:
129 asyncio.set_event_loop(old_loop)
130
131 def stop(self):

...........................................................................
C:\Users\HP\Anaconda3\lib\asyncio\base_events.py in run_forever(self=<_WindowsSelectorEventLoop running=True closed=False debug=False>)
417 sys.set_asyncgen_hooks(firstiter=self._asyncgen_firstiter_hook,
418 finalizer=self._asyncgen_finalizer_hook)
419 try:
420 events._set_running_loop(self)
421 while True:
--> 422 self._run_once()
self._run_once = <bound method BaseEventLoop._run_once of <_Windo...EventLoop running=True closed=False debug=False>>
423 if self._stopping:
424 break
425 finally:
426 self._stopping = False

...........................................................................
C:\Users\HP\Anaconda3\lib\asyncio\base_events.py in _run_once(self=<_WindowsSelectorEventLoop running=True closed=False debug=False>)
1427 logger.warning('Executing %s took %.3f seconds',
1428 _format_handle(handle), dt)
1429 finally:
1430 self._current_handle = None
1431 else:
-> 1432 handle._run()
handle._run = <bound method Handle._run of <Handle BaseAsyncIOLoop._handle_events(580, 1)>>
1433 handle = None # Needed to break cycles when an exception occurs.
1434
1435 def _set_coroutine_wrapper(self, enabled):
1436 try:

...........................................................................
C:\Users\HP\Anaconda3\lib\asyncio\events.py in _run(self=<Handle BaseAsyncIOLoop._handle_events(580, 1)>)
140 self._callback = None
141 self._args = None
142
143 def _run(self):
144 try:
--> 145 self._callback(*self._args)
self._callback = <bound method BaseAsyncIOLoop._handle_events of <tornado.platform.asyncio.AsyncIOMainLoop object>>
self._args = (580, 1)
146 except Exception as exc:
147 cb = _format_callback_source(self._callback, self._args)
148 msg = 'Exception in callback {}'.format(cb)
149 context = {

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\tornado\platform\asyncio.py in _handle_events(self=<tornado.platform.asyncio.AsyncIOMainLoop object>, fd=580, events=1)
112 self.writers.remove(fd)
113 del self.handlers[fd]
114
115 def _handle_events(self, fd, events):
116 fileobj, handler_func = self.handlers[fd]
--> 117 handler_func(fileobj, events)
handler_func = <function wrap..null_wrapper>
fileobj = <zmq.sugar.socket.Socket object>
events = 1
118
119 def start(self):
120 try:
121 old_loop = asyncio.get_event_loop()

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\tornado\stack_context.py in null_wrapper(*args=(<zmq.sugar.socket.Socket object>, 1), **kwargs={})
271 # Fast path when there are no active contexts.
272 def null_wrapper(*args, **kwargs):
273 try:
274 current_state = _state.contexts
275 _state.contexts = cap_contexts[0]
--> 276 return fn(*args, **kwargs)
args = (<zmq.sugar.socket.Socket object>, 1)
kwargs = {}
277 finally:
278 _state.contexts = current_state
279 null_wrapper._wrapped = True
280 return null_wrapper

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py in _handle_events(self=<zmq.eventloop.zmqstream.ZMQStream object>, fd=<zmq.sugar.socket.Socket object>, events=1)
445 return
446 zmq_events = self.socket.EVENTS
447 try:
448 # dispatch events:
449 if zmq_events & zmq.POLLIN and self.receiving():
--> 450 self._handle_recv()
self._handle_recv = <bound method ZMQStream._handle_recv of <zmq.eventloop.zmqstream.ZMQStream object>>
451 if not self.socket:
452 return
453 if zmq_events & zmq.POLLOUT and self.sending():
454 self._handle_send()

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py in _handle_recv(self=<zmq.eventloop.zmqstream.ZMQStream object>)
475 else:
476 raise
477 else:
478 if self._recv_callback:
479 callback = self._recv_callback
--> 480 self._run_callback(callback, msg)
self._run_callback = <bound method ZMQStream._run_callback of <zmq.eventloop.zmqstream.ZMQStream object>>
callback = <function wrap..null_wrapper>
msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
481
482
483 def _handle_send(self):
484 """Handle a send event."""

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py in _run_callback(self=<zmq.eventloop.zmqstream.ZMQStream object>, callback=<function wrap..null_wrapper>, *args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
427 close our socket."""
428 try:
429 # Use a NullContext to ensure that all StackContexts are run
430 # inside our blanket exception handler rather than outside.
431 with stack_context.NullContext():
--> 432 callback(*args, **kwargs)
callback = <function wrap..null_wrapper>
args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
kwargs = {}
433 except:
434 gen_log.error("Uncaught exception in ZMQStream callback",
435 exc_info=True)
436 # Re-raise the exception so that IOLoop.handle_callback_exception

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\tornado\stack_context.py in null_wrapper(*args=([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],), **kwargs={})
271 # Fast path when there are no active contexts.
272 def null_wrapper(*args, **kwargs):
273 try:
274 current_state = _state.contexts
275 _state.contexts = cap_contexts[0]
--> 276 return fn(*args, **kwargs)
args = ([<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>],)
kwargs = {}
277 finally:
278 _state.contexts = current_state
279 null_wrapper._wrapped = True
280 return null_wrapper

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\ipykernel\kernelbase.py in dispatcher(msg=[<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>])
278 if self.control_stream:
279 self.control_stream.on_recv(self.dispatch_control, copy=False)
280
281 def make_dispatcher(stream):
282 def dispatcher(msg):
--> 283 return self.dispatch_shell(stream, msg)
msg = [<zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>, <zmq.sugar.frame.Frame object>]
284 return dispatcher
285
286 for s in self.shell_streams:
287 s.on_recv(make_dispatcher(s), copy=False)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\ipykernel\kernelbase.py in dispatch_shell(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, msg={'buffers': [], 'content': {'allow_stdin': True, 'code': "fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))", 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2018, 10, 3, 23, 16, 31, 739419, tzinfo=tzutc()), 'msg_id': '2a12f227dc194643a2f3e2c845579a14', 'msg_type': 'execute_request', 'session': '8c19fc225dc641549355ba37ad32a56d', 'username': 'username', 'version': '5.2'}, 'metadata': {}, 'msg_id': '2a12f227dc194643a2f3e2c845579a14', 'msg_type': 'execute_request', 'parent_header': {}})
228 self.log.warn("Unknown message type: %r", msg_type)
229 else:
230 self.log.debug("%s: %s", msg_type, msg)
231 self.pre_handler_hook()
232 try:
--> 233 handler(stream, idents, msg)
handler = <bound method Kernel.execute_request of <ipykernel.ipkernel.IPythonKernel object>>
stream = <zmq.eventloop.zmqstream.ZMQStream object>
idents = [b'8c19fc225dc641549355ba37ad32a56d']
msg = {'buffers': [], 'content': {'allow_stdin': True, 'code': "fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))", 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2018, 10, 3, 23, 16, 31, 739419, tzinfo=tzutc()), 'msg_id': '2a12f227dc194643a2f3e2c845579a14', 'msg_type': 'execute_request', 'session': '8c19fc225dc641549355ba37ad32a56d', 'username': 'username', 'version': '5.2'}, 'metadata': {}, 'msg_id': '2a12f227dc194643a2f3e2c845579a14', 'msg_type': 'execute_request', 'parent_header': {}}
234 except Exception:
235 self.log.error("Exception in message handler:", exc_info=True)
236 finally:
237 self.post_handler_hook()

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\ipykernel\kernelbase.py in execute_request(self=<ipykernel.ipkernel.IPythonKernel object>, stream=<zmq.eventloop.zmqstream.ZMQStream object>, ident=[b'8c19fc225dc641549355ba37ad32a56d'], parent={'buffers': [], 'content': {'allow_stdin': True, 'code': "fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))", 'silent': False, 'stop_on_error': True, 'store_history': True, 'user_expressions': {}}, 'header': {'date': datetime.datetime(2018, 10, 3, 23, 16, 31, 739419, tzinfo=tzutc()), 'msg_id': '2a12f227dc194643a2f3e2c845579a14', 'msg_type': 'execute_request', 'session': '8c19fc225dc641549355ba37ad32a56d', 'username': 'username', 'version': '5.2'}, 'metadata': {}, 'msg_id': '2a12f227dc194643a2f3e2c845579a14', 'msg_type': 'execute_request', 'parent_header': {}})
394 if not silent:
395 self.execution_count += 1
396 self._publish_execute_input(code, parent, self.execution_count)
397
398 reply_content = self.do_execute(code, silent, store_history,
--> 399 user_expressions, allow_stdin)
user_expressions = {}
allow_stdin = True
400
401 # Flush output before sending the reply.
402 sys.stdout.flush()
403 sys.stderr.flush()

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\ipykernel\ipkernel.py in do_execute(self=<ipykernel.ipkernel.IPythonKernel object>, code="fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))", silent=False, store_history=True, user_expressions={}, allow_stdin=True)
203
204 self._forward_input(allow_stdin)
205
206 reply_content = {}
207 try:
--> 208 res = shell.run_cell(code, store_history=store_history, silent=silent)
res = undefined
shell.run_cell = <bound method ZMQInteractiveShell.run_cell of <ipykernel.zmqshell.ZMQInteractiveShell object>>
code = "fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))"
store_history = True
silent = False
209 finally:
210 self._restore_input()
211
212 if res.error_before_exec is not None:

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\ipykernel\zmqshell.py in run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, *args=("fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))",), **kwargs={'silent': False, 'store_history': True})
532 )
533 self.payload_manager.write_payload(payload)
534
535 def run_cell(self, *args, **kwargs):
536 self._last_traceback = None
--> 537 return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
self.run_cell = <bound method ZMQInteractiveShell.run_cell of <ipykernel.zmqshell.ZMQInteractiveShell object>>
args = ("fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))",)
kwargs = {'silent': False, 'store_history': True}
538
539 def _showtraceback(self, etype, evalue, stb):
540 # try to preserve ordering of tracebacks and print statements
541 sys.stdout.flush()

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, raw_cell="fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))", store_history=True, silent=False, shell_futures=True)
2657 -------
2658 result : :class:ExecutionResult
2659 """
2660 try:
2661 result = self._run_cell(
-> 2662 raw_cell, store_history, silent, shell_futures)
raw_cell = "fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))"
store_history = True
silent = False
shell_futures = True
2663 finally:
2664 self.events.trigger('post_execute')
2665 if not silent:
2666 self.events.trigger('post_run_cell', result)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in _run_cell(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, raw_cell="fitted_models = {}\n\n# Loop through model pipelin...ed'\n print('{0} has been fitted'.format(name))", store_history=True, silent=False, shell_futures=True)
2780 self.displayhook.exec_result = result
2781
2782 # Execute the user code
2783 interactivity = 'none' if silent else self.ast_node_interactivity
2784 has_raised = self.run_ast_nodes(code_ast.body, cell_name,
-> 2785 interactivity=interactivity, compiler=compiler, result=result)
interactivity = 'last_expr'
compiler = <IPython.core.compilerop.CachingCompiler object>
2786
2787 self.last_execution_succeeded = not has_raised
2788 self.last_execution_result = result
2789

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_ast_nodes(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, nodelist=[<_ast.Assign object>, <_ast.For object>], cell_name='', interactivity='none', compiler=<IPython.core.compilerop.CachingCompiler object>, result=<ExecutionResult object at 20ea44e4e80, executio...rue silent=False shell_futures=True> result=None>)
2898
2899 try:
2900 for i, node in enumerate(to_run_exec):
2901 mod = ast.Module([node])
2902 code = compiler(mod, cell_name, "exec")
-> 2903 if self.run_code(code, result):
self.run_code = <bound method InteractiveShell.run_code of <ipykernel.zmqshell.ZMQInteractiveShell object>>
code = <code object at 0x0000020EA2696660, file "", line 4>
result = <ExecutionResult object at 20ea44e4e80, executio...rue silent=False shell_futures=True> result=None>
2904 return True
2905
2906 for i, node in enumerate(to_run_interactive):
2907 mod = ast.Interactive([node])

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_code(self=<ipykernel.zmqshell.ZMQInteractiveShell object>, code_obj=<code object at 0x0000020EA2696660, file "", line 4>, result=<ExecutionResult object at 20ea44e4e80, executio...rue silent=False shell_futures=True> result=None>)
2958 outflag = True # happens in more places, so it's easier as default
2959 try:
2960 try:
2961 self.hooks.pre_run_code_hook()
2962 #rprint('Running code', repr(code_obj)) # dbg
-> 2963 exec(code_obj, self.user_global_ns, self.user_ns)
code_obj = <code object at 0x0000020EA2696660, file "", line 4>
self.user_global_ns = {'GradientBoostingClassifier': <class 'sklearn.ensemble.gradient_boosting.GradientBoostingClassifier'>, 'GridSearchCV': <class 'sklearn.model_selection._search.GridSearchCV'>, 'In': ['', 'from future import print_function\n\n# NumPy f...rn for easier visualization\nimport seaborn as sns', "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.csv')", "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.xlsx')", "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.xlsx')", 'import pandas as pd', "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.xlsx')", "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.csv')", 'df.shape', 'df.dtypes', 'df.head(10)', 'df.tail(10)', "df.hist(figsize=(10,10), xrot=-45, edgecolor='black')", 'plt.show()', 'df.describe()', "df.describe(include=['object'])", 'categorical_features = df.select_dtypes(include=...s.countplot(y = cat_feat, data=df)\n plt.show()', "sns.violinplot(y='ATTRITION', x = 'self satisfaction', data=df)", "sns.violinplot(y='ATTRITION', x='YEARS IN CURRENT ROLE',data=df)", "df.groupby('ATTRITION').mean()", ...], 'LogisticRegression': <class 'sklearn.linear_model.logistic.LogisticRegression'>, 'Out': {8: (122, 104), 9: Token Number int64
AGE ...action float64
Length: 104, dtype: object, 10: Token Number AGE F16-Leave F17-Leave PERM....01 4.179333

[10 rows x 104 columns], 11: Token Number AGE F16-Leave F17-Leave PE...121 4.206000

[10 rows x 104 columns], 12: array([[<matplotlib.axes._subplots.AxesSubplot o...ect at 0x0000020EA1F31AC8>]],
dtype=object), 14: Token Number AGE F16-Leave F1...00 4.330000 4.010000e+00 4.498400 , 15: PERMANENT CURRENT DEPARTMENT GEN...vision
freq 102 122 , 17: <matplotlib.axes._subplots.AxesSubplot object>, 18: <matplotlib.axes._subplots.AxesSubplot object>, 19: Token Number AGE F16-Leave ... 4.076316 3.868500 4.01 4.219077 , ...}, 'RandomForestClassifier': <class 'sklearn.ensemble.forest.RandomForestClassifier'>, 'StandardScaler': <class 'sklearn.preprocessing.data.StandardScaler'>, 'X': Token Number AGE F16-Leave F17-Leave J... 1

[122 rows x 449 columns], 'X_test': Token Number AGE F16-Leave F17-Leave J... 1

[25 rows x 449 columns], 'X_train': Token Number AGE F16-Leave F17-Leave J... 1

[97 rows x 449 columns], ...}
self.user_ns = {'GradientBoostingClassifier': <class 'sklearn.ensemble.gradient_boosting.GradientBoostingClassifier'>, 'GridSearchCV': <class 'sklearn.model_selection._search.GridSearchCV'>, 'In': ['', 'from future import print_function\n\n# NumPy f...rn for easier visualization\nimport seaborn as sns', "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.csv')", "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.xlsx')", "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.xlsx')", 'import pandas as pd', "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.xlsx')", "df = pd.read_csv('C:/Users/HP/Documents/Copy of Attrition & MCARES Data.csv')", 'df.shape', 'df.dtypes', 'df.head(10)', 'df.tail(10)', "df.hist(figsize=(10,10), xrot=-45, edgecolor='black')", 'plt.show()', 'df.describe()', "df.describe(include=['object'])", 'categorical_features = df.select_dtypes(include=...s.countplot(y = cat_feat, data=df)\n plt.show()', "sns.violinplot(y='ATTRITION', x = 'self satisfaction', data=df)", "sns.violinplot(y='ATTRITION', x='YEARS IN CURRENT ROLE',data=df)", "df.groupby('ATTRITION').mean()", ...], 'LogisticRegression': <class 'sklearn.linear_model.logistic.LogisticRegression'>, 'Out': {8: (122, 104), 9: Token Number int64
AGE ...action float64
Length: 104, dtype: object, 10: Token Number AGE F16-Leave F17-Leave PERM....01 4.179333

[10 rows x 104 columns], 11: Token Number AGE F16-Leave F17-Leave PE...121 4.206000

[10 rows x 104 columns], 12: array([[<matplotlib.axes._subplots.AxesSubplot o...ect at 0x0000020EA1F31AC8>]],
dtype=object), 14: Token Number AGE F16-Leave F1...00 4.330000 4.010000e+00 4.498400 , 15: PERMANENT CURRENT DEPARTMENT GEN...vision
freq 102 122 , 17: <matplotlib.axes._subplots.AxesSubplot object>, 18: <matplotlib.axes._subplots.AxesSubplot object>, 19: Token Number AGE F16-Leave ... 4.076316 3.868500 4.01 4.219077 , ...}, 'RandomForestClassifier': <class 'sklearn.ensemble.forest.RandomForestClassifier'>, 'StandardScaler': <class 'sklearn.preprocessing.data.StandardScaler'>, 'X': Token Number AGE F16-Leave F17-Leave J... 1

[122 rows x 449 columns], 'X_test': Token Number AGE F16-Leave F17-Leave J... 1

[25 rows x 449 columns], 'X_train': Token Number AGE F16-Leave F17-Leave J... 1

[97 rows x 449 columns], ...}
2964 finally:
2965 # Reset our crash handler in place
2966 sys.excepthook = old_excepthook
2967 except SystemExit as e:

...........................................................................
C:\Users\HP\Documents<ipython-input-63-67076fd7d5b3> in ()
4 for name, pipeline in pipelines.items():
5 # Create cross-validation object from pipeline and hyperparameters
6 model = GridSearchCV(pipeline, hyperparameters[name], cv = 10, n_jobs=-1)
7
8 # Fit model on X_train, y_train
----> 9 model.fit(X_train, y_train)
10
11 # Store model in fitted_models[name]
12 fitted_models[name] = model
13

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\model_selection_search.py in fit(self=GridSearchCV(cv=10, error_score='raise',
...ain_score='warn',
scoring=None, verbose=0), X= Token Number AGE F16-Leave F17-Leave J... 1

[97 rows x 449 columns], y=54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, groups=None, **fit_params={})
634 return_train_score=self.return_train_score,
635 return_n_test_samples=True,
636 return_times=True, return_parameters=False,
637 error_score=self.error_score)
638 for parameters, (train, test) in product(candidate_params,
--> 639 cv.split(X, y, groups)))
cv.split = <bound method StratifiedKFold.split of Stratifie...d(n_splits=10, random_state=None, shuffle=False)>
X = Token Number AGE F16-Leave F17-Leave J... 1

[97 rows x 449 columns]
y = 54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64
groups = None
640
641 # if one choose to see train score, "out" will contain train score info
642 if self.return_train_score:
643 (train_score_dicts, test_score_dicts, test_sample_counts, fit_time,

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in call(self=Parallel(n_jobs=-1), iterable=<generator object BaseSearchCV.fit..>)
784 if pre_dispatch == "all" or n_jobs == 1:
785 # The iterable was consumed all at once by the above for loop.
786 # No need to wait for async callbacks to trigger to
787 # consumption.
788 self._iterating = False
--> 789 self.retrieve()
self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=-1)>
790 # Make sure that we get a last message telling us we are done
791 elapsed_time = time.time() - self._start_time
792 self._print('Done %3i out of %3i | elapsed: %s finished',
793 (len(self._output), len(self._output),


Sub-process traceback:

ValueError Wed Oct 3 16:16:44 2018
PID: 7136 Python 3.6.5: C:\Users\HP\Anaconda3\python.exe
...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in call(self=<sklearn.externals.joblib.parallel.BatchedCalls object>)
126 def init(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
self.items = [(, (Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), Token Number AGE ... ... 1

[97 rows x 449 columns], 54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, {'score': }, array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), 0, {'logisticregression__C': 0.001}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': False, 'return_times': True, 'return_train_score': 'warn'})]
132
133 def len(self):
134 return self._size
135

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in (.0=<list_iterator object>)
126 def init(self, iterator_slice):
127 self.items = list(iterator_slice)
128 self._size = len(self.items)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
func =
args = (Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), Token Number AGE ... ... 1

[97 rows x 449 columns], 54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, {'score': }, array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), 0, {'logisticregression__C': 0.001})
kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': False, 'return_times': True, 'return_train_score': 'warn'}
132
133 def len(self):
134 return self._size
135

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\model_selection_validation.py in _fit_and_score(estimator=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[97 rows x 449 columns], y=54 0
18 0
64 0
103 1
85 0
45 ...9 0
Name: ATTRITION, Length: 97, dtype: int64, scorer={'score': }, train=array([10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2..., 87, 88, 89, 90, 91, 92, 93, 94, 95,
96]), test=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11]), verbose=0, parameters={'logisticregression__C': 0.001}, fit_params={}, return_train_score='warn', return_parameters=False, return_n_test_samples=True, return_times=True, error_score='raise')
453
454 try:
455 if y_train is None:
456 estimator.fit(X_train, **fit_params)
457 else:
--> 458 estimator.fit(X_train, y_train, **fit_params)
estimator.fit = <bound method Pipeline.fit of Pipeline(memory=No....0001,
verbose=0, warm_start=False))])>
X_train = Token Number AGE ... ... 1

[86 rows x 449 columns]
y_train = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params = {}
459
460 except Exception as e:
461 # Note fit time as time until error
462 fit_time = time.time() - start_time

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in fit(self=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
243 Returns
244 -------
245 self : Pipeline
246 This estimator
247 """
--> 248 Xt, fit_params = self._fit(X, y, **fit_params)
Xt = undefined
fit_params = {}
self._fit = <bound method Pipeline._fit of Pipeline(memory=N....0001,
verbose=0, warm_start=False))])>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
249 if self._final_estimator is not None:
250 self._final_estimator.fit(Xt, y, **fit_params)
251 return self
252

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit(self=Pipeline(memory=None,
steps=[('standardscal...0.0001,
verbose=0, warm_start=False))]), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
208 else:
209 cloned_transformer = clone(transformer)
210 # Fit or load from cache the current transfomer
211 Xt, fitted_transformer = fit_transform_one_cached(
212 cloned_transformer, None, Xt, y,
--> 213 **fit_params_steps[name])
fit_params_steps = {'logisticregression': {}, 'standardscaler': {}}
name = 'standardscaler'
214 # Replace the transformer of the step with the fitted
215 # transformer. This is necessary when loading the transformer
216 # from the cache.
217 self.steps[step_idx] = (name, fitted_transformer)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\externals\joblib\memory.py in call(self=NotMemorizedFunc(func=<function _fit_transform_one at 0x000001FC877EC8C8>), *args=(StandardScaler(copy=True, with_mean=True, with_std=True), None, Token Number AGE ... ... 1

[86 rows x 449 columns], 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64), **kwargs={})
357 # Should be a light as possible (for speed)
358 def init(self, func):
359 self.func = func
360
361 def call(self, *args, **kwargs):
--> 362 return self.func(*args, **kwargs)
self.func =
args = (StandardScaler(copy=True, with_mean=True, with_std=True), None, Token Number AGE ... ... 1

[86 rows x 449 columns], 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
kwargs = {}
363
364 def call_and_shelve(self, *args, **kwargs):
365 return NotMemorizedResult(self.func(*args, **kwargs))
366

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\pipeline.py in _fit_transform_one(transformer=StandardScaler(copy=True, with_mean=True, with_std=True), weight=None, X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
576
577
578 def _fit_transform_one(transformer, weight, X, y,
579 **fit_params):
580 if hasattr(transformer, 'fit_transform'):
--> 581 res = transformer.fit_transform(X, y, **fit_params)
res = undefined
transformer.fit_transform = <bound method TransformerMixin.fit_transform of ...Scaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params = {}
582 else:
583 res = transformer.fit(X, y, **fit_params).transform(X)
584 # if we have a weight for this transformer, multiply output
585 if weight is None:

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\base.py in fit_transform(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64, **fit_params={})
515 if y is None:
516 # fit method of arity 1 (unsupervised transformation)
517 return self.fit(X, **fit_params).transform(X)
518 else:
519 # fit method of arity 2 (supervised transformation)
--> 520 return self.fit(X, y, **fit_params).transform(X)
self.fit = <bound method StandardScaler.fit of StandardScaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
fit_params.transform = undefined
521
522
523 class DensityMixin(object):
524 """Mixin class for all density estimators in scikit-learn."""

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py in fit(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
585 y : Passthrough for Pipeline compatibility.
586 """
587
588 # Reset internal state before fitting
589 self._reset()
--> 590 return self.partial_fit(X, y)
self.partial_fit = <bound method StandardScaler.partial_fit of Stan...Scaler(copy=True, with_mean=True, with_std=True)>
X = Token Number AGE ... ... 1

[86 rows x 449 columns]
y = 8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64
591
592 def partial_fit(self, X, y=None):
593 """Online computation of mean and std on X for later scaling.
594 All of X is processed as a single batch. This is intended for cases

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py in partial_fit(self=StandardScaler(copy=True, with_mean=True, with_std=True), X= Token Number AGE ... ... 1

[86 rows x 449 columns], y=8 0
77 0
90 0
32 0
60 0
39 ...9 0
Name: ATTRITION, Length: 86, dtype: int64)
607 used for later scaling along the features axis.
608
609 y : Passthrough for Pipeline compatibility.
610 """
611 X = check_array(X, accept_sparse=('csr', 'csc'), copy=self.copy,
--> 612 warn_on_dtype=True, estimator=self, dtype=FLOAT_DTYPES)
self = StandardScaler(copy=True, with_mean=True, with_std=True)
613
614 # Even in the case of with_mean=False, we update the mean anyway
615 # This is needed for the incremental computation of the var
616 # See incr_mean_variance_axis and _incremental_mean_variance_axis

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_array(array=array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]]), accept_sparse=('csr', 'csc'), dtype=<class 'numpy.float64'>, order=None, copy=True, force_all_finite=True, ensure_2d=True, allow_nd=False, ensure_min_samples=1, ensure_min_features=1, warn_on_dtype=True, estimator=StandardScaler(copy=True, with_mean=True, with_std=True))
448 array = array.astype(np.float64)
449 if not allow_nd and array.ndim >= 3:
450 raise ValueError("Found array with dim %d. %s expected <= 2."
451 % (array.ndim, estimator_name))
452 if force_all_finite:
--> 453 _assert_all_finite(array)
array = array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]])
454
455 shape_repr = _shape_repr(array.shape)
456 if ensure_min_samples > 0:
457 n_samples = _num_samples(array)

...........................................................................
C:\Users\HP\Anaconda3\lib\site-packages\sklearn\utils\validation.py in _assert_all_finite(X=array([[2.0287700e+05, 4.6000000e+01, 2.3000000e...0000e+00,
0.0000000e+00, 1.0000000e+00]]))
39 # everything is finite; fall back to O(n) space np.isfinite to prevent
40 # false positives from overflow in sum method.
41 if (X.dtype.char in np.typecodes['AllFloat'] and not np.isfinite(X.sum())
42 and not np.isfinite(X).all()):
43 raise ValueError("Input contains NaN, infinity"
---> 44 " or a value too large for %r." % X.dtype)
X.dtype = dtype('float64')
45
46
47 def assert_all_finite(X):
48 """Throw a ValueError if X contains NaN or infinity.

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

@ujwal107
Copy link

ujwal107 commented Oct 3, 2018

plz someone help me Its urgent

@jnothman
Copy link
Member

jnothman commented Oct 4, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants