<commit_before>#!/usr/bin/env python
import os
import numpy as np
import hmmlearn.hmm 
from sklearn.externals import joblib
from sklearn.preprocessing import (
    scale,
    normalize
)
    
def run(model_save_path, 
    n_state, 
    covariance_type_string, 
    n_iteration,
    trials_group_by_folder_name):

    list_of_trials = trials_group_by_folder_name.values() 

    if not os.path.isdir(model_save_path):
        os.makedirs(model_save_path)

    one_trial_data_group_by_state = list_of_trials[0]
    state_amount = len(one_trial_data_group_by_state)

    start_prob = np.zeros(state_amount)
    start_prob[0] = 1

    training_data_group_by_state = {}
    training_length_array_group_by_state = {}

    for state_no in range(1, state_amount+1):
        length_array = []
        for trial_no in range(len(list_of_trials)):
            length_array.append(list_of_trials[trial_no][state_no].shape[0])
            if trial_no == 0:
                data_tempt = list_of_trials[trial_no][state_no]
            else:<commit_msg>fix bug in hmm model training: start_prob is for hidden states not for task states<commit_after>#!/usr/bin/env python
import os
import numpy as np
import hmmlearn.hmm 
from sklearn.externals import joblib
from sklearn.preprocessing import (
    scale,
    normalize
)
    
def run(model_save_path, 
    n_state, 
    covariance_type_string, 
    n_iteration,
    trials_group_by_folder_name):

    list_of_trials = trials_group_by_folder_name.values() 

    if not os.path.isdir(model_save_path):
        os.makedirs(model_save_path)

    one_trial_data_group_by_state = list_of_trials[0]
    state_amount = len(one_trial_data_group_by_state)

    start_prob = np.zeros(n_state)
    start_prob[0] = 1

    training_data_group_by_state = {}
    training_length_array_group_by_state = {}

    for state_no in range(1, state_amount+1):
        length_array = []
        for trial_no in range(len(list_of_trials)):
            length_array.append(list_of_trials[trial_no][state_no].shape[0])
            if trial_no == 0:
                data_tempt = list_of_trials[trial_no][state_no]
            else:
{'fraction_non_alphanumeric': 0.07919400187441425, 'fraction_numerical': 0.006560449859418931, 'mean_word_length': 3.366053169734151, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1451507', 'n_tokens_mistral': 779, 'n_tokens_neox': 735, 'n_words': 129}