Reputation: 5477
I'm extracting the F1_macro value using f1_score sklearn function.
I doing that for my Keras network, this is the code:
Y_dev_pred = self.model.predict([self.dev[0], self.dev[1]], batch_size=self.BatchSize, verbose=0)
Y_dev_pred = np.argmax(Y_dev_pred, axis=1)
self.Y_dev = np.argmax(self.dev[2], axis=1)
print('####### ', self.Y_dev.shape, ' ', Y_dev_pred.shape)
print(self.Y_dev, ' ### ', Y_dev_pred)
print(f1_score(self.Y_dev, Y_dev_pred, average='macro'))
Output:
####### (19647,) (19647,) [1 0 0 ... 2 0 2] ### [0 0 0 ... 2 1 0] Traceback (most recent call last): File "main.py", line 185, in <module> deep.run_model(reTrain=True) File ".../models/DL.py", line 477, in run_model self.evaluate_on_test() File ".../models/DL.py", line 448, in evaluate_on_test print(f1_score(self.Y_dev, Y_dev_pred, average='macro')) TypeError: f1_score() got an unexpected keyword argument 'average'
What is the problem, did I miss something?
Upvotes: 1
Views: 7823
Reputation: 11
My scikit learn is Name: scikit-learn Version: 0.24.2
I'm still getting this issue. My problem is multi-class not binary.
If i remove the average i got this error Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].
Upvotes: 0
Reputation: 404
I got this error when in my code i had another function called f1_score as well.
Upvotes: 1
Reputation: 332
Check if any of your y_true labels or y_predicted labels has only two classes? check the unique values in each. average macro works only for multiclass if any of the variables has only two classes it throws a error like this! and yes check version of your sklearn,
Upvotes: 0