An echo state network is an RNN whose recurrent weights are drawn at random, scaled to a chosen spectral radius, and never trained. Only the linear readout is learned, which turns training into ridge regression.
Implement esn_fit_predict(u_train, y_train, u_test, n_res, rho, input_scale, ridge, washout, seed):
u_* have shape (T,) (scalar input) or (T, d_in); targets y_train have shape (T,) or (T, d_out).rng = np.random.default_rng(seed); W_in = rng.uniform(-input_scale, input_scale, (n_res, d_in)); W = rng.uniform(-0.5, 0.5, (n_res, n_res)); then rescale W so its spectral radius (largest absolute eigenvalue) equals rho.u_train.washout states, form features , and solve (the bias is penalised too). has shape (n_res + 1, d_out).u_test and output for each test step.Return (radius, W_out, y_pred) where radius is the spectral radius of the rescaled W and y_pred has shape (T_test,) for 1-D targets, otherwise (T_test, d_out).