Created
October 22, 2018 15:56
-
-
Save pmarcelino/c8f8a421a9b88003f80bb1e9b4c034a6 to your computer and use it in GitHub Desktop.
SVM solution for the Dogs vs. Cats competition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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