Skip to content Skip to sidebar Skip to footer

Typeerror: Reduction Operation 'argmax' Not Allowed For This Dtype

I don't actually know what is wrong with my code. Could anyone help? from sklearn.linear_model import LogisticRegression from sklearn.cross_validation import KFold, cross_val_score

Solution 1:

I know where the problem is: the dtype of results_table['Mean recall score'] is object! the idxmax not allowed for the "object"

you should change it to float, here is my solution:

results_table['Mean recall score']=results_table['Mean recall'].astype('float64')

best_c = results_table.loc[results_table['Mean recall score'].idxmax()]['C_parameter']

And this will work!

Solution 2:

the last answer is right but might should change

results_table['Mean recall score']=results_table['Mean recall'].astype('float64')

to

results_table['Mean recall score']=results_table['Mean recall score'].astype('float64')

Post a Comment for "Typeerror: Reduction Operation 'argmax' Not Allowed For This Dtype"