0
$\begingroup$

I have the following frame of actual value,

[[0.1,0.2,0.3,0.4,0.5],
 [0.1,0.1,0.3,0.4,0.5],
 [0.1,0.1,0.3,0.4,0.1],
 [0.1,0.3,0.3,0.4,0.5],
 [0.1,0.2,0.2,0.4,0.4],
]

And I built my own model which predicted value as following:

[[0.2,0.4,0.3,0.4,0.1],
 [0.1,0.1,0.3,0.4,0.5],
 [0.2,0.2,0.2,0.4,0.1],
 [0.3,0.3,0.4,0.4,0.2],
 [0.5,0.2,0.2,0.4,0.4],
]

Each of one is in a csv file, I read both of them as a pandas frame and I processing them as following:

   arr1 = df1.values
   arr2 = df2.values
   import numpy as np
   from sklearn.metrics import hamming_loss, accuracy_score, precision_score, 
   recall_score, f1_score 
   from sklearn.metrics import multilabel_confusion_matrix
   y_true = np.array(arr1)
   y_pred = np.array(arr2)
   conf_mat=multilabel_confusion_matrix(y_true, y_pred)

and I get the following error,

if y_type not in ["binary", "multiclass", "multilabel-indicator"]:
--> 104         raise ValueError("{0} is not supported".format(y_type))
    105 
    106     if y_type in ["binary", "multiclass"]:
ValueError: continuous-multioutput is not supported

How can I get the sklearn report for my values?

$\endgroup$

1 Answer 1

0
$\begingroup$

Based on the metrics you import, I am guessing that your input data represents some sort of probability. However, your data is not normalized, so I might be wrong here.
In any case, Sklearn cannot calculate your metrics from data that is not a class-label or binary input. If you want to for example calculate the accuracy of your prediction, you have to transform your data from a probability (i.e. 80% a, 20% b) to a class (label: a) so that for each prediction Sklearn can compare your prediction to the ground truth data.

$\endgroup$
3
  • $\begingroup$ I would like to use these probabilities as classes for my data, I have 9 values from 0.1 to 0.9, Is it if I convert it from numerical representation to character or string representation, is that will work with sklearn.metrics? $\endgroup$ Nov 3, 2022 at 16:01
  • $\begingroup$ It is not the datatype that you're inputting which is the problem. You need to give sklearn a class-label for each datapoint not a probability. If your data is already in a format where the largest number is equivalent to the largest probability albeit not normalized, then simply applying np.argmax to your data will give you an input sklearn can work with. $\endgroup$ Nov 3, 2022 at 16:07
  • $\begingroup$ Thanks for your illustration, but pleas, if you can rewrite my code with the way you are illustrated to get my goal. $\endgroup$ Nov 3, 2022 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.