Skip to content

Instantly share code, notes, and snippets.

@danjo89
Created November 10, 2016 10:24
Show Gist options
  • Save danjo89/7db0fc3e145337969cec1f0e08a239fe to your computer and use it in GitHub Desktop.
Save danjo89/7db0fc3e145337969cec1f0e08a239fe to your computer and use it in GitHub Desktop.
Error Trace: Relevant Feature Selection
My Example
x = pd.DataFrame([[1,1,1,1,2,2,2,2,3,3,3,3],[5,6,5,5,4,5,4,3,1,1,2,3]]).T
x.columns=['ID', 'VALUES']
y = pd.DataFrame([7,8,9], index=[1,2,3])
relevant_features = ts.extract_relevant_features(x, y, column_id='ID')
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/pandas/computation/expressions.py:181: UserWarning: evaluating in Python space because the '*' operator is not supported by numexpr for the bool dtype, use '&' instead
unsupported[op_str]))
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/pandas/computation/expressions.py:181: UserWarning: evaluating in Python space because the '*' operator is not supported by numexpr for the bool dtype, use '&' instead
unsupported[op_str]))
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/numpy/lib/function_base.py:2487: RuntimeWarning: Degrees of freedom <= 0 for slice
warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning)
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/scipy/signal/spectral.py:772: UserWarning: nperseg = 256, is greater than input length = 4, using nperseg = 4
'using nperseg = {1:d}'.format(nperseg, x.shape[-1]))
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-54-e59070010ad9> in <module>()
----> 1 relevant_features = ts.extract_relevant_features(x, y, column_id='ID')
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/tsfresh/convenience/relevant_extraction.py in extract_relevant_features(timeseries_container, y, X, feature_extraction_settings, feature_selection_settings, column_id, column_sort, column_kind, column_value)
51 column_id=column_id, column_sort=column_sort,
52 column_kind=column_kind, column_value=column_value)
---> 53 X_sel = select_features(X_ext, y, feature_selection_settings=feature_selection_settings)
54
55 if X is None:
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/tsfresh/feature_selection/selection.py in select_features(X, y, feature_selection_settings)
98 y = pd.Series(y, index=X.index)
99
--> 100 df_bh = check_fs_sig_bh(X, y, feature_selection_settings)
101
102 return X.loc[:, df_bh[df_bh.rejected].Feature]
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/tsfresh/feature_selection/feature_selector.py in check_fs_sig_bh(X, y, settings)
95 # Only allow entries for which the target is known!
96 y = y.astype(np.float)
---> 97 X = X.copy().loc[~(y == np.NaN), :]
98
99 # Create the DataFrame df_features containing the information about the different hypotheses
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/pandas/core/indexing.py in __getitem__(self, key)
1292
1293 if type(key) is tuple:
-> 1294 return self._getitem_tuple(key)
1295 else:
1296 return self._getitem_axis(key, axis=0)
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/pandas/core/indexing.py in _getitem_tuple(self, tup)
787
788 # no multi-index, so validate all of the indexers
--> 789 self._has_valid_tuple(tup)
790
791 # ugly hack for GH #836
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/pandas/core/indexing.py in _has_valid_tuple(self, key)
140 if i >= self.obj.ndim:
141 raise IndexingError('Too many indexers')
--> 142 if not self._has_valid_type(k, i):
143 raise ValueError("Location based indexing can only have [%s] "
144 "types" % self._valid_types)
/.conda/envs/geopandas_python3/lib/python3.5/site-packages/pandas/core/indexing.py in _has_valid_type(self, key, axis)
1377
1378 raise KeyError("None of [%s] are in the [%s]" %
-> 1379 (key, self.obj._get_axis_name(axis)))
1380
1381 return True
KeyError: 'None of [ 0\n1 True\n2 True\n3 True] are in the [index]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment