def main(): parser = OptionParser(usage="usage: %prog [options] feature_file output_file meta_file") parser.add_option("-c", "--config-file", action="store", dest="config", default="gold.yml", help="Configuration file",) (options, args) = parser.parse_args() if len(args) != 3: parser.error("wrong number of arguments") config = GyroConfig.load(options.config) features = gyrodata.readCsvData(args[0]) output = gyrodata.readCsvData(args[1]) # global variable for simplicity global metadataPath metadataPath = args[2] model = getModel(config) # normalize features/output (may be false assumption) features = [[float(x) for x in l] for l in features] print "" accuracy = runData(config, features, output) # Output accuracy correctly if model.isDiscrete: print "Accuracy: " + "%.2f" % (accuracy * 100) + "%" else: print "Average Absolute Error: " + "%.2f" % accuracy
def checkValidFile(path, numKeys, minRecords): # check for valid values in acc file data = gyrodata.readCsvData(path) if len(data) < minRecords: return False # count all non-falsy keys keys = [len([e for e in l if e]) for l in data] return max(keys) == numKeys
def main(): parser = OptionParser(usage="usage: %prog [options] feature_file output_file meta_file") parser.add_option("-c", "--config-file", action="store", dest="config", default="gold.yml", help="Configuration file",) (options, args) = parser.parse_args() if len(args) != 3: parser.error("wrong number of arguments") config = GyroConfig.load(options.config) features = gyrodata.readCsvData(args[0]) output = gyrodata.readCsvData(args[1]) # normalize features/output (may be false assumption) features = [[float(x) for x in l] for l in features] print "" runData(config, features, output)
def readNumericData(path): data = gyrodata.readCsvData(path) return [[float(x or 0) for x in l] for l in data]