示例#1
0
def train_hmm_and_keep_track_of_log_likelihood(hmm, obs, n_iter=1, **kwargs):
    hmm.fit(obs, n_iter=1, **kwargs)
    loglikelihoods = []
    for n in xrange(n_iter):
        hmm.fit(obs, n_iter=1, init_params='', **kwargs)
        loglikelihoods.append(sum(hmm.score(x) for x in obs))
    return loglikelihoods
示例#2
0
def train_hmm_and_keep_track_of_log_likelihood(hmm, obs, n_iter=1, **kwargs):
    hmm.fit(obs, n_iter=1, **kwargs)
    loglikelihoods = []
    for n in xrange(n_iter):
        hmm.fit(obs, n_iter=1, init_params='', **kwargs)
        loglikelihoods.append(sum(hmm.score(x) for x in obs))
    return loglikelihoods
def test_hmms(hmms, chain, trajectory):
    """Returns the scores for a set of hmms over a single trajectory.
    
    Parameters:
    hmms: a dictionary where the keys are the names for the hmms the the values are MultinomialHMM instances.
    chain: the pre-processing chain created with create_preprocessing_chain.py
    trajectory: a [n_points, n_features] matrix to be preprocessed by chain.
    """

    input_traj = chain.transform(trajectory)
    scores = {}
    for name, hmm in hmms.iteritems():
        scores[name] = hmm.score([input_traj])
    return scores
def test_hmms(hmms, chain, trajectory):
    """Returns the scores for a set of hmms over a single trajectory.
    
    Parameters:
    hmms: a dictionary where the keys are the names for the hmms the the values are MultinomialHMM instances.
    chain: the pre-processing chain created with create_preprocessing_chain.py
    trajectory: a [n_points, n_features] matrix to be preprocessed by chain.
    """

    input_traj = chain.transform(trajectory)
    scores = {}
    for name, hmm in hmms.iteritems():
        scores[name] = hmm.score([input_traj])
    return scores
def test_hmms(hmms, pca, kmeans, trajectory):
    input_traj = kmeans.predict(pca.transform(trajectory))
    scores = {}
    for name, hmm in hmms.iteritems():
        scores[name] = hmm.score( [input_traj])
    return scores
示例#6
0
def test_hmms(hmms, pca, kmeans, trajectory):
    input_traj = kmeans.predict(pca.transform(trajectory))
    scores = {}
    for name, hmm in hmms.iteritems():
        scores[name] = hmm.score([input_traj])
    return scores