Created
December 13, 2013 16:17
-
-
Save madaan/7946708 to your computer and use it in GitHub Desktop.
Using adaboost with svm as weak learner [fails]
This file contains hidden or 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
def cvalidate(): | |
targetset = np.genfromtxt(open('trainLabels.csv','r'), dtype='f16') | |
y = [x for x in targetset] | |
trainset = np.genfromtxt(open('train.csv','r'), delimiter=',', dtype='f16') | |
X = np.array([x for x in trainset]) | |
X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size = 0.3, random_state = 0) | |
X_train, X_test = decomposition_pca(X_train, X_test) | |
parameters = {'kernel':('linear', 'rbf'), 'C':[1, 10]} | |
c_range = 10.0 ** np.arange(6.5,7.5,.25) | |
gamma_range = 10.0 ** np.arange(-2.5,0.5,.25) | |
parameters = {'kernel':['rbf'], 'C':c_range, 'gamma':gamma_range} | |
svr = SVC(probability=True) | |
clf = grid_search.GridSearchCV(svr, parameters) | |
bdt = AdaBoostClassifier(base_estimator = clf, | |
algorithm="SAMME", | |
n_estimators=200) | |
#bdt = AdaBoostClassifier(base_estimator=SVC(probability=True)) | |
bdt.fit(X_train, y_train) | |
print bdt.score(X_test, y_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment