2
I have a dataframe in the following format:
colunas = [
'COMEDY',
'CRIME',
'Classe Prevista'
]
precisao_df = pd.DataFrame(columns=colunas)
precisao_df['COMEDY'] = y_pred_proba[:,0]
precisao_df['CRIME'] = y_pred_proba[:,1]
precisao_df
And I want to do the following: for each line, if comedy > crime, expected class = comedy, if not crime. That is, the predicted class is the one my model gave the most probability of being. How can I make this expression?
Ex:
COMEDY CRIME Classe prevista
0 0.9 0.1 COMEDY
1 0.42 0.58 CRIME
In fact the
pandas
also haswhere
...df['Classe Prevista'].where(df.COMEDY>df.CRIME, 'COMEDY', inplace=True)
df['Classe Prevista'].where(df.COMEDY<df.CRIME, 'CRIME', inplace=True)
– nosklo