sklearn の Web サイトからサンプル コードを取得しました。
tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-3, 1e-4], 'C': [1, 10, 100, 1000]},
{'kernel': ['linear'], 'C': [1, 10, 100, 1000]}]
scores = [('f1', f1_score)]
for score_name, score_func in scores:
print "# Tuning hyper-parameters for %s" % score_name
print
clf = GridSearchCV( SVC(), tuned_parameters, score_func=score_func, n_jobs=-1, verbose=2 )
clf.fit(X_train, Y_train)
print "Best parameters set found on development set:"
print
print clf.best_estimator_
print
print "Grid scores on development set:"
print
for params, mean_score, scores in clf.grid_scores_:
print "%0.3f (+/-%0.03f) for %r" % (
mean_score, scores.std() / 2, params)
print
print "Detailed classification report:"
print
print "The model is trained on the full development set."
print "The scores are computed on the full evaluation set."
print
y_true, y_pred = Y_test, clf.predict(X_test)
print cross_validation.classification_report(y_true, y_pred)
print
X_train は、約 70 行の pandas DataFrame です。
出力は
[GridSearchCV] kernel=rbf, C=1, gamma=0.001 ....................................
[GridSearchCV] kernel=rbf, C=1, gamma=0.001 ....................................
[GridSearchCV] kernel=rbf, C=1, gamma=0.001 ....................................
[GridSearchCV] kernel=rbf, C=1, gamma=0.0001 ...................................
[Parallel(n_jobs=-1)]: Done 1 jobs | elapsed: 0.0s
[GridSearchCV] ........................... kernel=rbf, C=1, gamma=0.001 - 0.0s
[GridSearchCV] ........................... kernel=rbf, C=1, gamma=0.001 - 0.0s
[GridSearchCV] ........................... kernel=rbf, C=1, gamma=0.001 - 0.0s
[GridSearchCV] .......................... kernel=rbf, C=1, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=rbf, C=1, gamma=0.0001 ...................................
[GridSearchCV] kernel=rbf, C=1, gamma=0.0001 ...................................
[GridSearchCV] kernel=rbf, C=10, gamma=0.001 ...................................
[GridSearchCV] kernel=rbf, C=10, gamma=0.001 ...................................
[GridSearchCV] .......................... kernel=rbf, C=1, gamma=0.0001 - 0.0s
[GridSearchCV] .......................... kernel=rbf, C=1, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=rbf, C=10, gamma=0.001 ...................................
[GridSearchCV] .......................... kernel=rbf, C=10, gamma=0.001 - 0.0s
[GridSearchCV] .......................... kernel=rbf, C=10, gamma=0.001 - 0.0s
[GridSearchCV] kernel=rbf, C=10, gamma=0.0001 ..................................
[GridSearchCV] .......................... kernel=rbf, C=10, gamma=0.001 - 0.0s
[GridSearchCV] kernel=rbf, C=10, gamma=0.0001 ..................................
[GridSearchCV] kernel=rbf, C=10, gamma=0.0001 ..................................
[GridSearchCV] ......................... kernel=rbf, C=10, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=rbf, C=100, gamma=0.001 ..................................
[GridSearchCV] ......................... kernel=rbf, C=10, gamma=0.0001 - 0.0s
[GridSearchCV] ......................... kernel=rbf, C=10, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=rbf, C=100, gamma=0.001 ..................................
[GridSearchCV] ......................... kernel=rbf, C=100, gamma=0.001 - 0.0s
[GridSearchCV] kernel=rbf, C=100, gamma=0.001 ..................................
[GridSearchCV] kernel=rbf, C=100, gamma=0.0001 .................................
[GridSearchCV] ......................... kernel=rbf, C=100, gamma=0.001 - 0.0s
[GridSearchCV] kernel=rbf, C=100, gamma=0.0001 .................................
[GridSearchCV] ......................... kernel=rbf, C=100, gamma=0.001 - 0.0s
[GridSearchCV] kernel=rbf, C=100, gamma=0.0001 .................................
[GridSearchCV] kernel=rbf, C=1000, gamma=0.001 .................................
[GridSearchCV] ........................ kernel=rbf, C=100, gamma=0.0001 - 0.0s
[GridSearchCV] ........................ kernel=rbf, C=100, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=rbf, C=1000, gamma=0.001 .................................
[GridSearchCV] ........................ kernel=rbf, C=100, gamma=0.0001 - 0.0s
[GridSearchCV] ........................ kernel=rbf, C=1000, gamma=0.001 - 0.0s
[GridSearchCV] kernel=rbf, C=1000, gamma=0.001 .................................
[GridSearchCV] kernel=rbf, C=1000, gamma=0.0001 ................................
[GridSearchCV] kernel=rbf, C=1000, gamma=0.0001 ................................
[GridSearchCV] ........................ kernel=rbf, C=1000, gamma=0.001 - 0.0s
[GridSearchCV] kernel=rbf, C=1000, gamma=0.0001 ................................
[GridSearchCV] ........................ kernel=rbf, C=1000, gamma=0.001 - 0.0s
[GridSearchCV] ....................... kernel=rbf, C=1000, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=linear, C=1 ..............................................
[GridSearchCV] ....................... kernel=rbf, C=1000, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=linear, C=1 ..............................................
[GridSearchCV] kernel=linear, C=1 ..............................................
[GridSearchCV] ....................... kernel=rbf, C=1000, gamma=0.0001 - 0.0s
[GridSearchCV] kernel=linear, C=10 .............................................
そして、それは決して終わりません。Lion を搭載した Mac Book Pro で実行しています。私は何を間違っていますか?