def get_out_extension(otype):
    if otype == 'numpybin':
        ext = au.numpyio_ext()
    elif otype == 'octave':
        ext = au.octaveio_ext()
    elif otype == 'svmperf':
        ext = au.svmperfio_ext()
    elif otype == 'arff':
        ext = au.wekaio_ext()
    else:
        err = 'Output method not recognised!'
        raise IOError(err)

    return ext
Exemplo n.º 2
0
def get_out_extension (otype):
    if   otype  == 'numpybin':
        ext = au.numpyio_ext()
    elif otype  == 'octave':
        ext = au.octaveio_ext()
    elif otype  == 'svmperf':
        ext = au.svmperfio_ext()
    elif otype  == 'arff':
        ext = au.wekaio_ext()
    else:
        err = 'get_out_extension: Extension type not supported: ' + otype
        raise Exception(err)

    return ext
def get_out_extension(otype):
    if otype == "numpybin":
        ext = au.numpyio_ext()
    elif otype == "octave":
        ext = au.octaveio_ext()
    elif otype == "svmperf":
        ext = au.svmperfio_ext()
    elif otype == "arff":
        ext = au.wekaio_ext()
    else:
        err = "Output method not recognised!"
        raise IOError(err)

    return ext
def set_filename(outdir, filename, otype):
    filename = outdir + os.path.sep + filename

    if otype == 'numpybin':
        filename += au.numpyio_ext()

    elif otype == 'octave':
        filename += au.octaveio_ext()

    elif otype == 'svmperf':
        filename += au.svmperfio_ext()

    elif otype == 'arff':
        filename += au.wekaio_ext()

    else:
        err = 'Output method not recognised!'
        raise IOError(err)

    return filename
def set_filename (outdir, filename, otype):
   filename = outdir + os.path.sep + filename

   if   otype  == 'numpybin':
      filename += au.numpyio_ext()

   elif otype  == 'octave':
      filename += au.octaveio_ext()

   elif otype  == 'svmperf':
      filename += au.svmperfio_ext()

   elif otype  == 'arff':
      filename += au.wekaio_ext()

   else:
      err = 'Output method not recognised!'
      raise IOError(err)

   return filename
Exemplo n.º 6
0
def load_features(feats_file, labels_file):
    try:
        ext = au.get_extension(feats_file)

        if ext == au.numpyio_ext():
            feats = np.load(feats_file)

        elif ext == au.octaveio_ext():
            data = sio.loadmat(feats_file)
            feats = data['feats']
            labels = data['labels']

        elif ext == au.wekaio_ext():
            feats, meta = sio.arff.loadarff(featsfile)

        else:
            err = 'File extension not recognised: ' + feats_file
            raise IOError(err)

    except IOError:
        au.log.error("File not found: ", sys.exc_info()[0])

    except:
        au.log.error("Unexpected error:", sys.exc_info()[0])
        raise

    if labels_file:
        try:
            labels = np.loadtxt(labels_file)
        except IOError:
            au.log.error("File not found: ", labels_file)
        except:
            au.log.error("Unexpected error:", sys.exc_info()[0])
            raise

    return feats, labels
Exemplo n.º 7
0
def load_features (feats_file, labels_file):
   try:
      ext = au.get_extension(feats_file)

      if   ext == au.numpyio_ext ():
         feats = np.load(feats_file)

      elif ext == au.octaveio_ext():
         data   = sio.loadmat(feats_file)
         feats  = data['feats']
         labels = data['labels']

      elif ext == au.wekaio_ext  ():
         feats, meta = sio.arff.loadarff (featsfile)

      else:
         err = 'File extension not recognised: ' + feats_file
         raise IOError(err)

   except IOError:
      au.log.error("File not found: ", sys.exc_info()[0])

   except:
      au.log.error("Unexpected error:", sys.exc_info()[0])
      raise

   if labels_file:
      try:
         labels = np.loadtxt(labels_file)
      except IOError:
         au.log.error("File not found: ", labels_file)
      except:
         au.log.error("Unexpected error:", sys.exc_info()[0])
         raise

   return feats, labels