pykoop.shift_episodes

shift_episodes(X, n_inputs=0, episode_feature=False)

Shift episodes and truncate shifted inputs.

The Koopman matrix K approximately satisfies:

Theta_+ = Psi @ K.T

where Psi contains the unshifted states and inputs, and Theta_+ contains the shifted states.

The regressors used in KoopmanPipeline expect Psi as their X and Theta_+ as their y. This function breaks its input (also named X) into Psi and Theta_+ for use with these regressors.

Parameters:
  • X (np.ndarray) – Data matrix.

  • n_inputs (int) – Number of input features at the end of X.

  • episode_feature (bool) – True if first feature indicates which episode a timestep is from.

Returns:

Tuple whose first element is the unshifted array and whose second element is the shifted array with its inputs truncated. Both arrays have the same number of samples. Their episode features are stripped if present.

Return type:

Tuple[np.ndarray, np.ndarray]