I have a data set X and labels y for training and scoring a sklearn.SVC model. The data is split into X_train
and X_test
. I run a for-loop
to find the best possible value combination (i.e. best score) for two SVC parameters: C
and gamma
. I can print out the highest score, but how do I print the C and gamma values that were used for this particular score?
for C in np.arange(0.05, 2.05, 0.05):
for gamma in np.arange(0.001, 0.101, 0.001):
model = SVC(kernel='rbf', gamma=gamma, C=C)
model.fit(X_train, y_train)
score = model.score(X_test, y_test)
if score > best_score:
best_score = score
print('Highest Accuracy Score: ', best_score)