to_keras_3d

hhpy.modelling.to_keras_3d(x: Union[pandas.core.frame.DataFrame, numpy.ndarray], window: int, y: Union[pandas.core.frame.DataFrame, numpy.ndarray] = None, groupby: Union[Sequence[T_co], int, float, str, bytes, None, AbstractSet[T_co]] = None, groupby_to_dummy: bool = False, dropna: bool = True, reshape: bool = True) → Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]][source]

reformat a DataFrame / 2D array to become a keras compatible 3D array. If dropna is True the first window observations get dropped since they will contain NaN values in the required shifted elements.

Parameters:
  • x – numpy array or DataFrame
  • window – series-window, how many iterations to convolve
  • y – accompanying target / label DataFrame or numpy 2d array. If specified a modified version of y will be returned to match x’s shape where the first window elements have been dropped. [optional]
  • groupby – column to group by (shift observations in each group) [optional]
  • groupby_to_dummy – Whether to include the groupby value as pandas Dummy [optional]
  • dropna – Whether to drop na rows [optional]
  • reshape – Whether to reshape to keras format observations - timestamps - features [optional]
Returns:

if y is None: x as 3d array, else: Tuple[x, y]