def main(argv): output_file = 'objs.pickle' InputMethod = "FFT" if argv < 3: Usage() sys.exit(2) try: opts, args = getopt.getopt(argv, "hmfp:n:o:", ["positive=","negative=","output="]) except: Usage() sys.exit(2) for opt, arg in opts: if opt == '-h': Usage() sys.exit() elif opt in ('-p', '--positive'): positive_training_directory=arg elif opt in ('-n', '--negative'): negative_training_directory=arg elif opt in ('-o', '--output'): output_file=arg elif opt in ('-m'): InputMethod="MEL" elif opt in ('-f'): InputMethod="FFT" print "Using positive training directory ", positive_training_directory print "Using negative training directory ", negative_training_directory # Read the FFT data meow_list = [positive_training_directory, negative_training_directory] if InputMethod == "FFT": print "Using FFT Training" X, y = read_training_ffts(8000, meow_list) elif InputMethod == "MEL": print "Using MFCC Training" X, y = MakeMFCC.read_ceps(meow_list) else: print "No valid input method" sys.exit() # Split the data into test and train sets X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.2, random_state=0) # Perform the regression clf = LogisticRegression() clf.fit(X_train, y_train) # Test for an actual prediction y_pred = clf.predict(X_test) cm = confusion_matrix(y_test, y_pred) name = "TestName" title = "TestTitle" #plot_confusion_matrix(cm, meow_list, name, title) print "Confusion matrix of the data" print cm score = clf.score(X_test, y_test) print "Score" print score # If desired, this can be used to test alternate cross validation sets scores = cross_validation.cross_val_score(clf, X, y, cv=5) print scores print "Writing output to ", output_file with open(output_file, 'w') as f: pickle.dump(clf, f)