

def fit_hmm(Xs, Xtest, N_samples=100):
    model = MultinomialHMM(K, D)
    for X in Xs:
        model.add_data(smpl)
    samples = []
    lls = []
    test_lls = []
    pis = []
    zs = []
    timestamps = [time.time()]
    for smpl in progprint_xrange(N_samples):
        model.resample_model()
        timestamps.append(time.time())
        samples.append(model.copy_sample())
        lls.append(model.log_likelihood())
        test_lls.append(model.log_likelihood(Xtest))
        zs.append(model.stateseqs[0])
    lls = np.array(lls)
    test_lls = np.array(test_lls)
    pis = np.array(pis)
    zs = np.array(zs)
    timestamps = np.array(timestamps)
    timestamps -= timestamps[0]
    return (model, lls, test_lls, pis, zs, timestamps)

dataset/ETHPy150Open HIPS/pgmult/examples/multinomial_lds_2.py fit_hmm/VarMisuse@36/50 `X`->`smpl`