def test(nthreads, model, testsongs, npicks, winsize, finaldim, K, typecompress): """ Main function to do the testing Do the main pass with the number of given threads. Then, reads the tmp files, computes the score, delete the tmpfiles. INPUT - nthreads - number of threads to use - model - h5 files containing feats and year for all train songs - testsongs - songs to test on - npicks - number of samples to pick per song - winsize - window size (in beats) of a sample - finaldim - final dimension of the sample, something like 5? - K - K-nn parameter - typecompress - feature type, one of: 'picks', 'corrcoeff', 'cov' RETURN - nothing """ # initial time t1 = time.time() # do main pass tmpfiles = process_filelist_test_main_pass(nthreads, model, testsongs, npicks, winsize, finaldim, K, typecompress) if tmpfiles is None: print 'Something went wrong, tmpfiles are None' return # intermediate time t2 = time.time() stimelen = str(datetime.timedelta(seconds=t2 - t1)) print 'Main pass done after', stimelen sys.stdout.flush() # aggregate temp files year_real = [] year_pred = [] for tmpf in tmpfiles: h5 = tables.openFile(tmpf) year_real.extend(h5.root.data.year_real[:]) year_pred.extend(h5.root.data.year_pred[:]) h5.close() # delete tmp file os.remove(tmpf) # result BENCHMARK.evaluate(year_real, year_pred, verbose=1) # final time t3 = time.time() stimelen = str(datetime.timedelta(seconds=t3 - t1)) print 'Whole testing done after', stimelen # done return
def test(nthreads,model,testsongs,npicks,winsize,finaldim,K,typecompress): """ Main function to do the testing Do the main pass with the number of given threads. Then, reads the tmp files, computes the score, delete the tmpfiles. INPUT - nthreads - number of threads to use - model - h5 files containing feats and year for all train songs - testsongs - songs to test on - npicks - number of samples to pick per song - winsize - window size (in beats) of a sample - finaldim - final dimension of the sample, something like 5? - K - K-nn parameter - typecompress - feature type, one of: 'picks', 'corrcoeff', 'cov' RETURN - nothing """ # initial time t1 = time.time() # do main pass tmpfiles = process_filelist_test_main_pass(nthreads,model,testsongs, npicks,winsize,finaldim,K, typecompress) if tmpfiles is None: print 'Something went wrong, tmpfiles are None' return # intermediate time t2 = time.time() stimelen = str(datetime.timedelta(seconds=t2-t1)) print 'Main pass done after',stimelen; sys.stdout.flush() # aggregate temp files year_real = [] year_pred = [] for tmpf in tmpfiles: h5 = tables.openFile(tmpf) year_real.extend( h5.root.data.year_real[:] ) year_pred.extend( h5.root.data.year_pred[:] ) h5.close() # delete tmp file os.remove(tmpf) # result BENCHMARK.evaluate(year_real,year_pred,verbose=1) # final time t3 = time.time() stimelen = str(datetime.timedelta(seconds=t3-t1)) print 'Whole testing done after',stimelen # done return
def measure(testf, vwout, verbose=1): """ measure the result from the test file and vw output """ years_real = [] years_pred = [] f_real = open(testf, 'r') f_pred = open(vwout, 'r') for line_real in f_real.xreadlines(): line_pred = f_pred.readline().strip() years_real.append(convert_back_to_year(float(line_real.split(' ')[0]))) years_pred.append(convert_back_to_year(float(line_pred))) # close files f_real.close() f_pred.close() # measure return BENCHMARK.evaluate(years_real, years_pred, verbose=verbose)
def measure(testf, vwout, verbose=1): """ measure the result from the test file and vw output """ years_real = [] years_pred = [] f_real = open(testf, "r") f_pred = open(vwout, "r") for line_real in f_real.xreadlines(): line_pred = f_pred.readline().strip() years_real.append(convert_back_to_year(float(line_real.split(" ")[0]))) years_pred.append(convert_back_to_year(float(line_pred))) # close files f_real.close() f_pred.close() # measure return BENCHMARK.evaluate(years_real, years_pred, verbose=verbose)