Open otoofim opened 5 years ago
Without data, this issue is hard to debug. Searching for the error message (which comes from sklearn), the most likely cause is that either your target or your predictions have wrong values. Make sure that your targets are integers from 0 to n-1 and that your y_proba
consists of n classes.
@otoofim Any updates on this? If not, I will assume that this issue was caused by the things in my previous post and close it.
I haven't solved the problem, yet. I am using GridSearchCV with cv = 5. It evaluates the model with no problem on validation set at the end of each epoch and print the results at the end of training but when I use the callback to print the val and training acc during training I am getting the error.
accuracy_score is a classification metric, you cannot use it for a regression problem. You get the error because these regression model do not produce binary outcomes, but continuous (float) numbers (as all regression model do); so, when scikit-learn attempts to calculate the accuracy by comparing a binary number (true label) with a float (predicted value), it not unexpectedly gives an error. And this cause is clearly hinted at the error message itself:
The sklearn.metrics.accuracy_score(y_true, y_pred) method defines y_pred as:
y_pred : 1d array-like, or label indicator array / sparse matrix. Predicted labels, as returned by a classifier.
Which means y_pred has to be an array of 1's or 0's (predicated labels). They should not be probabilities.
Hi,
I am using the following callback to get accuracy at the end of each epoch:
However, at the time of evaluation on the validation set I am getting the error below:
My RNN implementation:
My Trainer class:
Trainer object: