examples/run_sweep.py
def process(in_path, annot_beats=False, feature="mfcc", framesync=False,
            boundaries_id="gt", labels_id=None, n_jobs=4, config=None):
    """Sweeps parameters across the specified algorithm."""

    results_file = "results_sweep_boundsE%s_labelsE%s.csv" % (boundaries_id,
                                                              labels_id)

    if labels_id == "cnmf3" or boundaries_id == "cnmf3":
        config = io.get_configuration(feature, annot_beats, framesync,
                                      boundaries_id, labels_id)

        hh = range(15, 33)
        RR = range(15, 40)
        ranks = range(3, 6)
        RR_labels = range(11, 12)
        ranks_labels = range(6, 7)
        all_results = pd.DataFrame()
        for rank in ranks:
            for h in hh:
                for R in RR:
                    for rank_labels in ranks_labels:
                        for R_labels in RR_labels:
                            config["h"] = h
                            config["R"] = R
                            config["rank"] = rank
                            config["rank_labels"] = rank_labels
                            config["R_labels"] = R_labels
                            config["features"] = None

                            # Run process
                            msaf.run.process(
                                in_path, n_jobs=n_jobs,
                                boundaries_id=boundaries_id,
                                labels_id=labels_id, config=config)

                            # Compute evaluations
                            results = msaf.eval.process(
                                in_path, boundaries_id, labels_id,
                                save=True, n_jobs=n_jobs, config=config)

                            # Save avg results
                            new_columns = {"config_h": h, "config_R": R,
                                           "config_rank": rank,
                                           "config_R_labels": R_labels,
                                           "config_rank_labels": rank_labels}
                            results = results.append([new_columns],
                                                     ignore_index=True)
                            all_results = all_results.append(results.mean(),
                                                             ignore_index=True)
                            all_results.to_csv(results_file)

    elif labels_id is None and boundaries_id == "sf":
        config = io.get_configuration(feature, annot_beats, framesync,
                                      boundaries_id, labels_id)

        MM = range(20, 32)
        mm = range(3, 4)
        kk = np.arange(0.03, 0.1, 0.01)
        Mpp = range(16, 32)
        ott = np.arange(0.02, 0.1, 0.01)
        all_results = pd.DataFrame()
        for k in kk:
            for ot in ott:
                for m in mm:
                    for M in MM:
                        for Mp in Mpp:
                            config["M_gaussian"] = M
                            config["m_embedded"] = m
                            config["k_nearest"] = k
                            config["Mp_adaptive"] = Mp
                            config["offset_thres"] = ot
                            config["features"] = None

                            # Run process
                            msaf.run.process(
                                in_path, n_jobs=n_jobs,
                                boundaries_id=boundaries_id,
                                labels_id=labels_id, config=config)

                            # Compute evaluations
                            results = msaf.eval.process(
                                in_path, boundaries_id, labels_id,
                                save=True, n_jobs=n_jobs, config=config)

                            # Save avg results
                            new_columns = {"config_M": M, "config_m": m,
                                           "config_k": k, "config_Mp": Mp,
                                           "config_ot": ot}
                            results = results.append([new_columns],
                                                     ignore_index=True)
                            all_results = all_results.append(results.mean(),
                                                             ignore_index=True)
                            all_results.to_csv(results_file)

    else:
        logging.error("Can't sweep parameters for %s algorithm. "
                      "Implement me! :D")
def process(in_path, annot_beats=False, feature="mfcc", framesync=False,
            boundaries_id="gt", labels_id=None, n_jobs=4, config=None):
    """Sweeps parameters across the specified algorithm."""

    results_file = "results_sweep_boundsE%s_labelsE%s.csv" % (boundaries_id,
                                                              labels_id)

    if labels_id == "cnmf3" or boundaries_id == "cnmf3":
        config = io.get_configuration(feature, annot_beats, framesync,
                                      boundaries_id, labels_id)

        hh = range(15, 33)
        RR = range(15, 40)
        ranks = range(3, 6)
        RR_labels = range(11, 12)
        ranks_labels = range(6, 7)
        all_results = pd.DataFrame()
        for rank in ranks:
            for h in hh:
                for R in RR:
                    for rank_labels in ranks_labels:
                        for R_labels in RR_labels:
                            config["h"] = h
                            config["R"] = R
                            config["rank"] = rank
                            config["rank_labels"] = rank_labels
                            config["R_labels"] = R_labels
                            config["features"] = None

                            # Run process
                            msaf.run.process(
                                in_path, n_jobs=n_jobs,
                                boundaries_id=boundaries_id,
                                labels_id=labels_id, config=config)

                            # Compute evaluations
                            results = msaf.eval.process(
                                in_path, boundaries_id, labels_id,
                                save=True, n_jobs=n_jobs, config=config)

                            # Save avg results
                            new_columns = {"config_h": h, "config_R": R,
                                           "config_rank": rank,
                                           "config_R_labels": R_labels,
                                           "config_rank_labels": rank_labels}
                            results = results.append([new_columns],
                                                     ignore_index=True)
                            all_results = all_results.append(results.mean(),
                                                             ignore_index=True)
                            all_results.to_csv(results_file)

    elif labels_id is None and boundaries_id == "sf":
        config = io.get_configuration(feature, annot_beats, framesync,
                                      boundaries_id, labels_id)

        MM = range(20, 32)
        mm = range(3, 4)
        kk = np.arange(0.03, 0.1, 0.01)
        Mpp = range(16, 32)
        ott = np.arange(0.02, 0.1, 0.01)
        all_results = pd.DataFrame()
        for k in kk:
            for ot in ott:
                for m in mm:
                    for M in MM:
                        for Mp in Mpp:
                            config["M_gaussian"] = M
                            config["m_embedded"] = m
                            config["k_nearest"] = k
                            config["Mp_adaptive"] = Mp
                            config["offset_thres"] = ot
                            config["features"] = None

                            # Run process
                            msaf.run.process(
                                in_path, n_jobs=n_jobs,
                                boundaries_id=boundaries_id,
                                labels_id=labels_id, config=config)

                            # Compute evaluations
                            results = msaf.eval.process(
                                in_path, boundaries_id, labels_id,
                                save=True, n_jobs=n_jobs, config=config)

                            # Save avg results
                            new_columns = {"config_M": M, "config_m": m,
                                           "config_k": k, "config_Mp": Mp,
                                           "config_ot": ot}
                            results = results.append([new_columns],
                                                     ignore_index=True)
                            all_results = all_results.append(results.mean(),
                                                             ignore_index=True)
                            all_results.to_csv(results_file)

    else:
        logging.error("Can't sweep parameters for %s algorithm. "
                      "Implement me! :D")
def process ( in_path , annot_beats = False , feature = "mfcc" , framesync = False , boundaries_id = "gt" , labels_id = None , n_jobs = 4 , config = None ) : results_file = "results_sweep_boundsE%s_labelsE%s.csv" % ( boundaries_id , labels_id ) if labels_id == "cnmf3" or boundaries_id == "cnmf3" : config = io . get_configuration ( feature , annot_beats , framesync , boundaries_id , labels_id ) hh = range ( 15 , 33 ) RR = range ( 15 , 40 ) ranks = range ( 3 , 6 ) RR_labels = range ( 11 , 12 ) ranks_labels = range ( 6 , 7 ) all_results = pd . DataFrame ( ) for rank in ranks : for h in hh : for R in RR : for rank_labels in ranks_labels : for R_labels in RR_labels : config [ "h" ] = h config [ "R" ] = R config [ "rank" ] = rank config [ "rank_labels" ] = rank_labels config [ "R_labels" ] = R_labels config [ "features" ] = None # Run process msaf . run . process ( in_path , n_jobs = n_jobs , boundaries_id = boundaries_id , labels_id = labels_id , config = config ) # Compute evaluations results = msaf . eval . process ( in_path , boundaries_id , labels_id , save = True , n_jobs = n_jobs , config = config ) # Save avg results new_columns = { "config_h" : h , "config_R" : R , "config_rank" : rank , "config_R_labels" : R_labels , "config_rank_labels" : rank_labels } results = results . append ( [ new_columns ] , ignore_index = True ) all_results = all_results . append ( results . mean ( ) , ignore_index = True ) all_results . to_csv ( results_file ) elif labels_id is None and boundaries_id == "sf" : config = io . get_configuration ( feature , annot_beats , framesync , boundaries_id , labels_id ) MM = range ( 20 , 32 ) mm = range ( 3 , 4 ) kk = np . arange ( 0.03 , 0.1 , 0.01 ) Mpp = range ( 16 , 32 ) ott = np . arange ( 0.02 , 0.1 , 0.01 ) all_results = pd . DataFrame ( ) for k in kk : for ot in ott : for m in mm : for M in MM : for Mp in Mpp : config [ "M_gaussian" ] = M config [ "m_embedded" ] = m config [ "k_nearest" ] = k config [ "Mp_adaptive" ] = Mp config [ "offset_thres" ] = ot config [ "features" ] = None # Run process msaf . run . process ( in_path , n_jobs = n_jobs , boundaries_id = boundaries_id , labels_id = labels_id , config = config ) # Compute evaluations results = msaf . eval . process ( in_path , boundaries_id , labels_id , save = True , n_jobs = n_jobs , config = config ) # Save avg results new_columns = { "config_M" : M , "config_m" : m , "config_k" : k , "config_Mp" : Mp , "config_ot" : ot } results = results . append ( [ new_columns ] , ignore_index = True ) all_results = all_results . append ( results . mean ( ) , ignore_index = True ) all_results . to_csv ( results_file ) else : logging . error ( "Can't sweep parameters for %s algorithm. " "Implement me! :D" )
Sweeps parameters across the specified algorithm.
Sweeps parameters across the specified algorithm .