I have the following pandas dataframe:
| ID | Class | LR | XG | SV | BEST_R2 |
|---|---|---|---|---|---|
| 1 | Class1 | .76 | .78 | .99 | .99 |
| 2 | Class2 | .92 | .89 | .91 | .92 |
| 3 | Class3 | .87 | .95 | .87 | .95 |
This is a dataframe with the R2 of each of a series of machine learning models (LR/XG/SV) for each ID. The column "BEST_R2" represents the best R2 score for that ID across models (.max(axis=1)). I need another column with the model name for best score. For example, the dataframe below. Any tips on how to achieve this programmatically?
| ID | Class | LR | XG | SV | BEST_R2 | BEST MODEL |
|---|---|---|---|---|---|---|
| 1 | Class1 | .76 | .78 | .99 | .99 | SV |
| 2 | Class2 | .92 | .89 | .91 | .92 | LR |
| 3 | Class3 | .87 | .95 | .87 | .95 | XG |
