예제 #1
0
파일: fdd.py 프로젝트: akionakamura/fdd
def _train_single(data, n_components, n_pc, covar_types, verbose, n_jobs, n_iter_search):
    model = PGMM(n_components=n_components,
                 n_pc=n_pc,
                 covariance_type=covar_types,
                 verbose=verbose)
    single_start = time()
    model.fit(data)
    single_end = time()
    logging.info("Single PGMM took %.2f seconds."
      % (single_end - single_start))
    return model
예제 #2
0
def _train_single(data, n_components, n_pc, covar_types, verbose, n_jobs,
                  n_iter_search):
    model = PGMM(n_components=n_components,
                 n_pc=n_pc,
                 covariance_type=covar_types,
                 verbose=verbose)
    single_start = time()
    model.fit(data)
    single_end = time()
    logging.info("Single PGMM took %.2f seconds." %
                 (single_end - single_start))
    return model
예제 #3
0
파일: fdd.py 프로젝트: akionakamura/fdd
def train_with_parameters(params, data_broadcast):
    data = data_broadcast.value
    n_components = params[0]
    n_pc = params[1]

    covariance_type = covar_type_int[params[2]]
    model = PGMM(n_components=n_components,
                 n_pc=n_pc,
                 covariance_type=covariance_type, tol=1e-6)
    try:
        model.fit(data)
        return model.bic(data), model
    except:
        # If failed, return the BIC as infite so the model will be discarted.
        return float("inf"), None
예제 #4
0
def train_with_parameters(params, data_broadcast):
    data = data_broadcast.value
    n_components = params[0]
    n_pc = params[1]

    covariance_type = covar_type_int[params[2]]
    model = PGMM(n_components=n_components,
                 n_pc=n_pc,
                 covariance_type=covariance_type,
                 tol=1e-6)
    try:
        model.fit(data)
        return model.bic(data), model
    except:
        # If failed, return the BIC as infite so the model will be discarted.
        return float("inf"), None
예제 #5
0
def _train_random(data, n_components, n_pc, covar_types, verbose, n_jobs,
                  n_iter_search):
    param_distribution = {
        'n_components': n_components,
        'n_pc': n_pc,
        'covariance_type': covar_types,
        'verbose': [verbose]
    }
    random_search = RandomizedSearchCV(PGMM(),
                                       param_distributions=param_distribution,
                                       n_iter=n_iter_search,
                                       scoring=PGMM.bic,
                                       verbose=verbose,
                                       n_jobs=n_jobs)
    random_start = time()
    random_search.fit(data)
    random_end = time()
    logging.info(
        "RandomSearchCV took %.2f seconds for %d candidate parameter settings."
        % (random_end - random_start, len(random_search.grid_scores_)))
    return random_search.best_estimator_
예제 #6
0
def _train_grid(data, n_components, n_pc, covar_types, verbose, n_jobs,
                n_iter_search):
    param_grid = [{
        'n_components': n_components,
        'n_pc': n_pc,
        'covariance_type': covar_types,
        'verbose': [verbose]
    }]

    grid_search = GridSearchCV(PGMM(),
                               param_grid=param_grid,
                               scoring=PGMM.bic,
                               verbose=verbose,
                               n_jobs=n_jobs)
    grid_start = time()
    grid_search.fit(data)
    grid_end = time()
    logging.info(
        'GridSearchCV took %.2f seconds for %d candidate parameter settings.' %
        (grid_end - grid_start, len(grid_search.grid_scores_)))
    return grid_search.best_estimator_