Skip to content

Instantly share code, notes, and snippets.

@pmarcelino
Created October 22, 2018 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmarcelino/c8f8a421a9b88003f80bb1e9b4c034a6 to your computer and use it in GitHub Desktop.
Save pmarcelino/c8f8a421a9b88003f80bb1e9b4c034a6 to your computer and use it in GitHub Desktop.
SVM solution for the Dogs vs. Cats competition
# Build model
import sklearn
from sklearn.cross_validation import train_test_split
from sklearn.grid_search import GridSearchCV
from sklearn.svm import LinearSVC
X_train, y_train = svm_features.reshape(300,7*7*512), svm_labels
param = [{
"C": [0.01, 0.1, 1, 10, 100]
}]
svm = LinearSVC(penalty='l2', loss='squared_hinge') # As in Tang (2013)
clf = GridSearchCV(svm, param, cv=10)
clf.fit(X_train, y_train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment