0
valid1 = plot_validation_curve(rand_search.best_estimator_, X_train, y_train,
                               cv=StratifiedKFold(n_splits=5), param_range=np.arange(2,100,2),
                               param_name = 'max_depth', scoring='f1')

I am using the plot_validation_curve fxn from sklearn. Let's say I pick out a spot on the curve that I think is the best. Now I want to confirm the actual x, y values. How do I label the points on the curve itself? Thanks!

I tried to label data points as one would with matplotlib but it didnt work.

fan-yang
  • 13
  • 3
  • Is `plot_validation_curve` a function from sklearn? I can't find it in the documentation https://scikit-learn.org/stable/search.html?q=plot_validation_curve – Maria K Jun 22 '23 at 18:18
  • no, that's a custom modification which essentially returns: fig, axes https://github.com/fan-yang-md/codingnomads/blob/main/data-science-machine-learning-main/notebooks/plotting.py – fan-yang Jun 22 '23 at 22:52

1 Answers1

0

Based on the comment it seems like the task is to label points on the matplotlib plot, when all the values are given (param_range as x-axis, train_scores, test_scores as y-axes). You can check out this answer to add labelling Scatter plot with different text at each data point.

Based on the answer there adding this to your code will help to annotate train scores:

for i, param_val in enumerate(param_range):
    axes.annotate(param_val, (param_range[i], train_scores_mean[i]))

And the same goes for annotating the other curves. You can also add x-values as text if needed.

Maria K
  • 1,491
  • 1
  • 3
  • 14