-1
TypeError: unsupported operand type(s) for /: 'dict' and 'int'

`

**Here is my code** 
x = df[header] 
clf=GaussianNB()
      
scoring = {
    'accuracy' : make_scorer(accuracy_score),
    'precision' : make_scorer(precision_score,average = 'micro'),
    'recall' : make_scorer(recall_score,average = 'micro'),
    'f1_score' : make_scorer(f1_score,average = 'micro')
} 
            
scores = cross_validate(clf, x, y, scoring=scoring, cv=5)
        
print(np.mean(scores))

When I run this code, it gives me this error and when I try to print(scores['precision']) print like this, it gives a key error of precision. Kindly suggest me how can I improve my code and also calculate multiple accuracies by using cross-validate for multiclass.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
Fatima
  • 11
  • 2

1 Answers1

0

if you google cross_validate you get scikit cross_validate. in the arguments for scoring, for dictionary it says:

a dictionary with metric names as keys and callables as values.

maybe you're having a hard time sending a callable with an argument. try this:

scoring = {'accuracy' : lambda: make_scorer(accuracy_score),
               ...
              } 
diggusbickus
  • 1,537
  • 3
  • 7
  • 15