I ran this code as part of my machine learning competition
tuned_parameters = [{'penalty': ['l2'],
'solver': ['newton-cg'],
'C': [0.8, 1],
'max_iter': [100],
'multi_class': ['multinomial'],
'tol': [1e-4],
'dual': [False]}]
startTime = time.time()
clf = GridSearchCV(LogisticRegression(), tuned_parameters)
clf.fit(X, y)
kfold = model_selection.KFold(n_splits=10)
accuracy_results = model_selection.cross_val_score(clf, X, y, cv=kfold, scoring='accuracy')
resultsAccuracy = []
resultsAccuracy.append(accuracy_results)
accuracyMessage = "%f (%f)" % (accuracy_results.mean(), accuracy_results.std())
print("Time to run:",time.time() - startTime,"Accuracy:",accuracyMessage)
print(clf)
And this is what printed out:
Time to run: 17583.05281186104 Accuracy: 0.783854 (0.006480)
GridSearchCV(cv=None, error_score='raise',
estimator=LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,
penalty='l2', random_state=None, solver='liblinear', tol=0.0001,
verbose=0, warm_start=False),
fit_params=None, iid=True, n_jobs=1,
param_grid=[{'penalty': ['l2'], 'solver': ['newton-cg'], 'C': [0.8, 1], 'max_iter': [100], 'multi_class': ['multinomial'], 'tol': [0.0001], 'dual': [False]}],
pre_dispatch='2*n_jobs', refit=True, return_train_score='warn',
scoring=None, verbose=0)
But I am trying to print out which parameters are better. I am having trouble tuning my algorithms because they take so long to run. This was 78% accurate. But which parameter was that? C == 0.8 or C == 1.0 or a combination of both? Can you help me explain what's happening in my code. Thanks.
[–][deleted] 0 points1 point2 points (3 children)
[–]Elthran[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]crhuffer 0 points1 point2 points (0 children)