def classify_perceptron(): print "perceptron" (X_train, y_train), (X_test, y_test) = util.load_all_feat() print "original X_train shape", X_train.shape clf = Perceptron() clf.fit(X_train, y_train) pred = clf.predict(X_test) print "accuracy score:", accuracy_score(y_test, pred)
def classifiy_svm(): print "SVM" (X_train, y_train), (X_test, y_test) = util.load_all_feat() print "original X_train shape", X_train.shape clf = LinearSVC() clf.fit(X_train, y_train) pred = clf.predict(X_test) print "accuracy score:", accuracy_score(y_test, pred)
def classify_sgd(loss="hinge"): print "SGD Clasifier with loss function({})".format(loss) (X_train, y_train), (X_test, y_test) = util.load_all_feat() X_train = X_train[:, :4096] X_test = X_test[:, :4096] clf = SGDClassifier(loss=loss, n_jobs=-1) clf.fit(X_train, y_train) pred = clf.predict(X_test) print "accuracy score:", accuracy_score(y_test, pred) nclass = len(clf.coef_)
def classify_logistic(): print "logistic regression" (X_train, y_train), (X_test, y_test) = util.load_all_feat() print "original X_train shape", X_train.shape clf = RandomizedLogisticRegression(n_jobs=2) clf.fit(X_train, y_train) # clf = LogisticRegression() # clf.fit(X_train, y_train) pred = clf.predict(X_test) print "accuracy score:", accuracy_score(y_test, pred) import ipdb; ipdb.set_trace() # XXX BREAKPOINT