Skip to content

Instantly share code, notes, and snippets.

@romeokienzler
Created May 14, 2018 11:27
Show Gist options
  • Save romeokienzler/22dc787728680d46e12bc3c825274123 to your computer and use it in GitHub Desktop.
Save romeokienzler/22dc787728680d46e12bc3c825274123 to your computer and use it in GitHub Desktop.
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/preprocessing/label.py:111: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
y = column_or_1d(y, warn=True)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-12-1c13669bcaa5> in <module>()
5
6 pipeline = (trans(LabelEncoder(), in_cols=['class']) + trans(None, ['source', 'x','y','z'])) | (trans(StandardScaler(), in_cols=['x','y','z']) + trans(None, ['source', 'class']))
----> 7 df_scaled = pipeline.fit_transform(df)
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/pipeline.py in fit_transform(self, X, y, **fit_params)
281 Xt, fit_params = self._fit(X, y, **fit_params)
282 if hasattr(last_step, 'fit_transform'):
--> 283 return last_step.fit_transform(Xt, y, **fit_params)
284 elif last_step is None:
285 return Xt
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/ibex/_base.py in fit_transform(self, X, y, **fit_params)
445
446 Xts = joblib.Parallel(n_jobs=self.n_jobs)(
--> 447 joblib.delayed(_fit_transform)(trans, weight, X, y, **fit_params) for _, trans, weight in self._iter())
448 return self.__concat(Xts)
449
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __call__(self, iterable)
777 # was dispatched. In particular this covers the edge
778 # case of Parallel used with an exhausted iterator.
--> 779 while self.dispatch_one_batch(iterator):
780 self._iterating = True
781 else:
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in dispatch_one_batch(self, iterator)
623 return False
624 else:
--> 625 self._dispatch(tasks)
626 return True
627
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in _dispatch(self, batch)
586 dispatch_timestamp = time.time()
587 cb = BatchCompletionCallBack(dispatch_timestamp, len(batch), self)
--> 588 job = self._backend.apply_async(batch, callback=cb)
589 self._jobs.append(job)
590
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/externals/joblib/_parallel_backends.py in apply_async(self, func, callback)
109 def apply_async(self, func, callback=None):
110 """Schedule a func to be run"""
--> 111 result = ImmediateResult(func)
112 if callback:
113 callback(result)
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/externals/joblib/_parallel_backends.py in __init__(self, batch)
330 # Don't delay the application, to avoid keeping the input
331 # arguments in memory
--> 332 self.results = batch()
333
334 def get(self):
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __call__(self)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
132
133 def __len__(self):
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in <listcomp>(.0)
129
130 def __call__(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
132
133 def __len__(self):
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/ibex/_base.py in _fit_transform(transformer, weight, X, y, *args, **kwargs)
355 def _fit_transform(transformer, weight, X, y, *args, **kwargs):
356 if hasattr(transformer, 'fit_transform'):
--> 357 res = transformer.fit_transform(X, y, *args, **kwargs)
358 else:
359 res = transformer.fit(X, y, *args, **kwargs).transform(X)
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/ibex/_function_transformer.py in fit_transform(self, X, y)
114
115 if in_cols is not None:
--> 116 Xt = Xt[in_cols]
117
118 if self.func is None:
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/pandas/core/frame.py in __getitem__(self, key)
2131 if isinstance(key, (Series, np.ndarray, Index, list)):
2132 # either boolean or fancy integer index
-> 2133 return self._getitem_array(key)
2134 elif isinstance(key, DataFrame):
2135 return self._getitem_frame(key)
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/pandas/core/frame.py in _getitem_array(self, key)
2175 return self._take(indexer, axis=0, convert=False)
2176 else:
-> 2177 indexer = self.loc._convert_to_indexer(key, axis=1)
2178 return self._take(indexer, axis=1, convert=True)
2179
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
1248 # if it cannot handle
1249 indexer, objarr = labels._convert_listlike_indexer(
-> 1250 obj, kind=self.name)
1251 if indexer is not None:
1252 return indexer
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/pandas/core/indexes/multi.py in _convert_listlike_indexer(self, keyarr, kind)
1804 mask = check == -1
1805 if mask.any():
-> 1806 raise KeyError('%s not in index' % keyarr[mask])
1807
1808 return indexer, keyarr
KeyError: "['x' 'y' 'z'] not in index"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment