"type": "float",
                    "value": "data.state",
                    "is_index": True,
                    "retrieval_method": "radius-n",
                    "retrieval_method_params": param,
                },
                "act": {"type": "float", "value": "data.action", "is_index": False, "retrieval_method": "cosine"},
                "delta_state": {"type": "float", "value": "data.next_state - data.state", "is_index": False},
            }

            model = CASML(
                CbTData(
                    case_t_template,
                    rho=args.rho,
                    tau=args.tau,
                    sigma=args.sigma,
                    plot_reuse=False,
                    plot_reuse_params="original_origin",
                ),
                ncomponents=args.ncomponents,
            )

            with Timer() as tm:
                for j, states in enumerate(train[i]):
                    # Train CASML's case base and hmm with states and actions
                    model.fit(states, actions)
            print ("Model trained in %.03f sec." % tm.time)

            failed = 0
            sampled = np.zeros((ntrials, d, n))
            ncases = model._cb_t._counter - 1
            "retrieval_method": args.retrieval_method,
            "retrieval_method_params": args.retrieval_method_params
        },
        "act": {
            "type": "float",
            "value": "data.action",
            "is_index": False,
            "retrieval_method": "cosine",
        },
        "delta_state": {
            "type": "float",
            "value": "data.next_state - data.state",
            "is_index": False,
        }
    }
    model = CASML(CbTData(case_t_template, rho=args.rho, tau=args.tau, sigma=args.sigma),
                  ncomponents=args.ncomponents)

    n = obs.shape[0]
    action_error = -np.inf * np.ones(n)
    delta_error = -np.inf * np.ones(n)

    for i, states in enumerate(obs):
        # Train CASML's case base and hmm with states and actions
        model.fit(states, actions)

        # Test model
        cntr = 0
        iter_ = 0
        while cntr < 10:
            sampled = None
            try: