Created
July 31, 2020 06:25
-
-
Save ra312/b5f67968bd5aff44314e229986eab060 to your computer and use it in GitHub Desktop.
label_prop_plot_roc_auc_score
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
import matplotlib.pyplot as plt | |
def label_prop_test(model, kernel, params_list, X_train, X_test, y_train, y_test): | |
plt.figure(figsize=(20,10)) | |
n, g = 0, 0 | |
roc_scores = [] | |
if kernel == 'rbf': | |
for g in params_list: | |
lp = model(kernel=kernel, n_neighbors=n, gamma=g, max_iter=100000, tol=0.0001) | |
lp.fit(X_train, y_train) | |
roc_scores.append(roc_auc_score(y_test, lp.predict_proba(X_test), multi_class='ovo')) | |
if kernel == 'knn': | |
for n in params_list: | |
lp = model(kernel=kernel, n_neighbors=n, gamma=g, max_iter=100000, tol=0.0001) | |
lp.fit(X_train, y_train) | |
roc_scores.append(roc_auc_score(y_test, lp.predict_proba(X_test), multi_class='ovo')) | |
plt.figure(figsize=(16,8)); | |
plt.plot(params_list, roc_scores) | |
plt.title('Label Propagation ROC AUC with ' + kernel + ' kernel') | |
plt.show() | |
print('Best metrics value is at {}'.format(params_list[np.argmax(roc_scores)])) |
Author
ra312
commented
Apr 2, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment