def predict_sequence(model, df, transition_matrix, measurement_cost, prior=[(1 / class_set) for _ in range(class_set)]):
    belief = np.reshape(prior, (class_set, 1))
    for time in np.sort(df.time.unique()):
        df_step = df[(df['time'] == time)].copy()
        if measurement_cost:
            selected_sensors = information_selection(df_step, model, belief, measurement_cost)
        else:
            selected_sensors = df_step.index
        df.loc[(selected_sensors, 'Selected')] = True
        for (i, row) in df_step.loc[selected_sensors].iterrows():
            row = row.to_frame().transpose()
            prop_likelihood = model.predict_proba(row)
            posterior = (prop_likelihood[0, :, np.newaxis] * belief)
            posterior = (posterior / posterior.sum())
            belief = posterior
        df['belief'] = np.nan
        df['belief'] = df['belief'].astype(object)
        for index in df_step.index:
            df.loc[(index, 'belief')] = [belief]
            df.loc[(index, 'prediction')] = (belief.argmax() + 1)
        belief = (transition_matrix @ np.reshape(belief, (class_set, 1)))
    return df
def predict_sequence(model, df, transition_matrix, measurement_cost, prior=[(1 / class_set) for _ in range(class_set)]):
    belief = np.reshape(prior, (class_set, 1))
    for time in np.sort(df.time.unique()):
        df_step = df[(df['time'] == time)].copy()
        if measurement_cost:
            selected_sensors = information_selection(df_step, model, belief, measurement_cost)
        else:
            selected_sensors = df_step.index
        df.loc[(selected_sensors, 'Selected')] = True
        for (i, row) in df_step.loc[selected_sensors].iterrows():
            row = row.to_frame().transpose()
            prop_likelihood = model.predict_proba(row)
            posterior = (prop_likelihood[0, :, np.newaxis] * belief)
            posterior = (posterior / posterior.sum())
            belief = posterior
        df['belief'] = np.nan
        df['belief'] = df['belief'].astype(object)
        for index in df_step.index:
            df.loc[(index, 'belief')] = [belief]
            df.loc[(index, 'prediction')] = (belief.argmax() + 1)
        belief = (transition_matrix @ np.reshape(belief, (class_set, 1)))
    return df