コード例 #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
ファイル: test_hmm.py プロジェクト: Scott-Alex/scikit-learn
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
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
コード例 #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