def structure_discrete_hmsvm_bmrm(m_data_dict=data_dict):
    import shogun as sg
    try:
        _ = sg.create_machine('DualLibQPBMSOSVM')
    except:
        print('DualLibQPBMSOSVM not available')
        return
    labels_array = m_data_dict['label'][0]
    idxs = numpy.nonzero((labels_array == (- 1)))
    labels_array[idxs] = 0
    labels = sg.SequenceLabels(labels_array, 250, 500, 2)
    features = sg.RealMatrixFeatures(m_data_dict['signal'].astype(float), 250, 500)
    num_obs = 4
    model = sg.create_structured_model('HMSVMModel', features=features, labels=labels, state_model_type='SMT_TWO_STATE', num_obs=num_obs)
    sosvm = sg.create_machine('DualLibQPBMSOSVM', model=model, labels=labels, m_lambda=5000.0)
    sosvm.train()
    predicted = sosvm.apply(features)
    evaluator = sg.create_evaluation('StructuredAccuracy')
    acc = evaluator.evaluate(predicted, labels)
def structure_discrete_hmsvm_bmrm(m_data_dict=data_dict):
    import shogun as sg
    try:
        _ = sg.create_machine('DualLibQPBMSOSVM')
    except:
        print('DualLibQPBMSOSVM not available')
        return
    labels_array = m_data_dict['label'][0]
    idxs = numpy.nonzero((labels_array == (- 1)))
    labels_array[idxs] = 0
    labels = sg.SequenceLabels(labels_array, 250, 500, 2)
    features = sg.RealMatrixFeatures(m_data_dict['signal'].astype(float), 250, 500)
    num_obs = 4
    model = sg.create_structured_model('HMSVMModel', features=features, labels=labels, state_model_type='SMT_TWO_STATE', num_obs=num_obs)
    sosvm = sg.create_machine('DualLibQPBMSOSVM', model=model, labels=labels, m_lambda=5000.0)
    sosvm.train()
    predicted = sosvm.apply(features)
    evaluator = sg.create_evaluation('StructuredAccuracy')
    acc = evaluator.evaluate(predicted, labels)