Пример #1
0
    if foldno:
        mdir += '_' + foldno

    #setting the stats folder
    statsdir = outdir + os.path.sep + au.stats_str()
    if expname:
        statsdir += '_' + expname
    if foldno:
        statsdir += '_' + foldno

    #setting a string with step parameters
    step_params = ' ' + measure_fname + ' ' + mdir

    absolute_str = ''
    if absval:
        absolute_str = ' ' + au.abs_str()
    step_params += absolute_str

    leave_str = ''
    if leave > -1:
        leave_str = ' excluding subject ' + str(leave)
    step_params += leave_str

    #checking if this measure has already been done
    endstep = au.measure_str() + step_params

    stepdone = au.is_done(chkf, endstep)
    #add pluses to output dir if it already exists
    if stepdone:
        while os.path.exists(mdir):
            mdir += '+'
Пример #2
0
def save_data (outdir, prefix, dataname, otype, excluding, leave, feats, labels, exclfeats, exclulabels, dmin, dmax, scale, scale_min, scale_max, lthr, uthr, thrp, absolute):

    #setting output file name
    ofname = au.feats_str()

    if leave > -1:
        ofname += '.' + au.excluded_str() + str(leave)

    if absolute:  ofname += '.' + au.abs_str()
    if lthr:      ofname += '.lthr_' + str(lthr)
    if uthr:      ofname += '.uthr_' + str(uthr)
    if thrp:      ofname += '.thrP_' + str(thrp)
    if scale:     ofname += '.' + au.scaled_str()

    if excluding:
        excl_ofname  = au.excluded_str() + '_' + ofname
        exclfilename = get_filepath (outdir, excl_ofname , otype)

    if prefix:
        ofname = prefix + '_' + ofname
        excl_ofname = prefix + '_' + excl_ofname

    filename = get_filepath (outdir, ofname, otype)

    #writing in a text file the scaling values of this training set
    if scale:
        write_scalingrange_file (outdir + os.path.sep + ofname + '.scaling_range', dmin, dmax, scale_min, scale_max)

    #saving binary file depending on output type
    if otype == 'numpybin':
        np.save (filename, feats)

        if excluding:
            np.save (exclfilename, exclfeats)

    elif otype == 'octave':
        sio.savemat (filename, {au.feats_str(): feats, au.labels_str(): labels})
        if excluding:
            exclulabels[exclulabels == 0] = -1
            sio.savemat (exclfilename, {au.feats_str(): exclfeats, au.labels_str(): exclulabels})

    elif otype == 'svmperf':
        labels[labels == 0] = -1
        ae.write_svmperf_dat(filename, dataname, feats, labels)

        if excluding:
            exclulabels[exclulabels == 0] = -1
            ae.write_svmperf_dat(exclfilename, dataname, exclfeats, exclulabels)

    elif otype == 'arff':
        featnames = np.arange(nfeats) + 1
        ae.write_arff (filename, dataname, featnames, feats, labels)

        if excluding:
            ae.write_arff (exclfilename, dataname, featnames, exclfeats, exclulabels)

    else:
        err = 'Output method not recognised!'
        au.log.error(err)
        sys.exit(-1)

    return [filename, exclfilename]
Пример #3
0
      mdir += '_' + foldno

   #setting the stats folder
   statsdir = outdir + os.path.sep + au.stats_str()
   if expname:
      statsdir += '_' + expname
   if foldno:
      statsdir += '_' + foldno


   #setting a string with step parameters
   step_params = ' ' + measure_fname + ' ' + mdir

   absolute_str = ''
   if absval:
      absolute_str = ' ' + au.abs_str()
   step_params += absolute_str

   leave_str = ''
   if leave > -1:
      leave_str = ' excluding subject ' + str(leave)
   step_params += leave_str

   #checking if this measure has already been done
   endstep = au.measure_str() + step_params

   stepdone = au.is_done(chkf, endstep)
   #add pluses to output dir if it already exists
   if stepdone:
      while os.path.exists (mdir):
         mdir += '+'