1
import pandas as pd

data = {'param_svm__C': [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
        'mean_test_score': [0.544298584899676, 0.5590809668304138, 0.5618705653377272, 0.5621819268675948, 0.5614353187928475,
                            0.5619234762611298, 0.5602971591216594, 0.5567186683040781, 0.5556217529098489, 0.553737884840016]}
df = pd.DataFrame(data)

   param_svm__C  mean_test_score
0           1.0         0.544299
1           2.0         0.559081
2           3.0         0.561871
3           4.0         0.562182
4           5.0         0.561435
5           6.0         0.561923
6           7.0         0.560297
7           8.0         0.556719
8           9.0         0.555622
9          10.0         0.553738

I want param_svm__C to be my y-axis and mean_test_score to be the value (color). I tried:

df_reshaped = df.pivot("param_svm__C", "mean_test_score")
sns.heatmap(df_reshaped, cmap="mako")

But df_reshaped returns the first column only, which is not what I need.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Caterina
  • 775
  • 9
  • 26

0 Answers0