Example #1
0
def train_with_bic():

    print("training with bic")

    from my_model_selectors import SelectorBIC

    training = asl.build_training(
        features_ground
    )  # Experiment here with different feature sets defined in part 1
    sequences = training.get_all_sequences()
    Xlengths = training.get_all_Xlengths()
    for word in words_to_train:
        start = timeit.default_timer()
        model = SelectorBIC(sequences,
                            Xlengths,
                            word,
                            min_n_components=2,
                            max_n_components=15,
                            random_state=14).select()
        end = timeit.default_timer() - start
        if model is not None:
            print(
                "Training complete for {} with {} states with time {} seconds".
                format(word, model.n_components, end))
        else:
            print("Training failed for {}".format(word))
Example #2
0
def run_bic(asl, features_ground, words_to_train, min_c, max_c, rand_s):
    # Copied from asl_recognizer.ipynb for IDE debugging using breakpoints.
    # Execute the implementation of SelectorBIC in module my_model_selectors.py
    from my_model_selectors import SelectorBIC

    training = asl.build_training(features_ground)

    print("BIC Available Training words - words: ", training.words)
    print("BIC Quantity of Training words - num_items: ", training.num_items)
    print("BIC Chosen Training words: ", words_to_train)
    print("BIC Chosen Features: ", features_ground)

    sequences = training.get_all_sequences()
    Xlengths = training.get_all_Xlengths()

    for word in words_to_train:
        start = timeit.default_timer()
        model = SelectorBIC(sequences,
                            Xlengths,
                            word,
                            min_n_components=min_c,
                            max_n_components=max_c,
                            random_state=rand_s).select()
        end = timeit.default_timer() - start
        if model is not None:
            print(
                "Training complete for {} with {} states with time {} seconds".
                format(word, model.n_components, end))
        else:
            print("Training failed for {}".format(word))
Example #3
0
 def test_select_bic_interface(self):
     model = SelectorBIC(self.sequences,
                         self.xlengths,
                         'VEGETABLE',
                         min_n_components=2,
                         max_n_components=15).select()
     self.assertGreaterEqual(model.n_components, 2)
Example #4
0
def test_selectorBIC():
    for word in words_to_train:
        start = timeit.default_timer()
        model = SelectorBIC(sequences,
                            Xlengths,
                            word,
                            min_n_components=2,
                            max_n_components=15,
                            random_state=14).select()
        end = timeit.default_timer() - start
        if model is not None:
            print(
                "Training complete for {} with {} states with time {} seconds".
                format(word, model.n_components, end))
        else:
            print("Training failed for {}".format(word))
Example #5
0
    else:
        print("Training failed for {}".format(word))

# TODO: Implement SelectorBIC in module my_model_selectors.py
from my_model_selectors import SelectorBIC

training = asl.build_training(
    features_ground
)  # Experiment here with different feature sets defined in part 1
sequences = training.get_all_sequences()
Xlengths = training.get_all_Xlengths()
for word in words_to_train:
    start = timeit.default_timer()
    model = SelectorBIC(sequences,
                        Xlengths,
                        word,
                        min_n_components=2,
                        max_n_components=15,
                        random_state=14).select()
    end = timeit.default_timer() - start
    if model is not None:
        print("Training complete for {} with {} states with time {} seconds".
              format(word, model.n_components, end))
    else:
        print("Training failed for {}".format(word))

# TODO: Implement SelectorDIC in module my_model_selectors.py
from my_model_selectors import SelectorDIC

training = asl.build_training(
    features_ground
)  # Experiment here with different feature sets defined in part 1
Example #6
0
 def vest_select_bic_interface(self):
     model = SelectorBIC(self.sequences, self.xlengths, 'FRANK').select()
     self.assertGreaterEqual(model.n_components, 2)
     model = SelectorBIC(self.sequences, self.xlengths,
                         'VEGETABLE').select()
     self.assertGreaterEqual(model.n_components, 2)