• Register
1 vote
1.3k views

Problem :

I am facing bellow strange error
undefinedmetricwarning: precision is ill-defined and being set to 0.0 due to no predicted samples.
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had faced similar issue in the past.

 Please use the bellow lines of code

from sklearn.metrics import f1_score
metrics.f1_score(y_test, y_pred, labels=np.unique(y_pred))

This will remove your warning and will give you the result you wanted

9 7 4
38,600 points

Related questions

0 votes
1 answer 330 views
330 views
Problem : I am new to Python, I want to do the simple nearest neighbors classification but I am always facing below error while trying to execute following code. “ValueError: Found input variables with inconsistent numbers of samples: [489, 1890]” My code snippet as below : myneigh = KNeighborsClassifier(n_neighbors=3) myneigh.fit(X_bus, y_bus) How can I fix above error?
asked Feb 25, 2020 mphil 2.3k points
1 vote
1 answer 31 views
31 views
Problem : Why I got the error : ImportError: No module named model_selection I am trying to use train_test_split function. Any ideas on what I need to do to fix this? Thanks!
asked Mar 12 Sabbir Hossain 14.6k points
0 votes
1 answer 2 views
2 views
Problem: So I have 20 different nominal categorical variables which are independent variables. Each of these variables 2-10 categories.These independent variables are string type and will be used to predict a dependent variable called price, which is a ... the group itself. I've found correlation between continuous variables for both independent and dependent variables. Help is much appreciated.
asked 3 days ago anika11 32k points
0 votes
1 answer 7 views
7 views
Problem: How to fix this error: How to solve Python/Scikit-Learn - Can't handle mix of multiclass and continuous - -
asked Mar 19 Wafa Abu Yousef 6.1k points
0 votes
1 answer 170 views
170 views
Problem: I'm trying to fit an SGDRegressor to my data and then check the accuracy. The fitting works fine, but then the predictions are not in the same datatype(?) as the original target data, and I get the error ValueError: Can't handle mix of multiclass and continuous
asked Jan 9 Mashhoodch 13k points
0 votes
2 answers 128 views
128 views
I'm trying to fit an SGDRegressor to my data and then check the accuracy. The fitting works fine, but then the predictions are not in the same datatype(?) as the original target data, and I get the error ValueError: Can't handle mix of multiclass and ... fit(X, y) predictions = clf.predict(X_test) print "Accuracy:", ms.accuracy_score(y_test,predictions) What should I do differently? Thank you!
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 2 views
2 views
Problem: I have a highly imbalanced dataset and I want to perform a binary classification. When reading some posts I found that sklearn provides class_weight="balanced" for imbalanced datasets. So, my classifier code is as follows. clf=RandomForestClassifier(random_state = 42, class_weight= ... ? If so, is there any better way of doing this in sklearn? I am happy to provide more details if needed.
asked 1 day ago anika11 32k points
0 votes
1 answer 1 view
1 view
Problem: I'm getting the error Multi output target data is not supported with label binarization. Someone help.
asked 2 days ago salim1 60.6k points
0 votes
1 answer 5 views
5 views
Problem: The following code from sklearn import metrics import numpy as np y_true = np.array([[0.2,0.8,0],[0.9,0.05,0.05]]) y_predict = np.array([[0.5,0.5,0.0],[0.5,0.4,0.1]]) metrics.log_loss(y_true, y_predict) produces the ... not supported with label binarization I am curious why. I am trying to re-read definition of log loss and cannot find anything that would make computations incorrect.
asked 5 days ago muktaa 34.4k points
0 votes
1 answer 514 views
514 views
Problem: np.nan is an invalid document, expected byte or unicode string.
asked Feb 21 charles mathews 5.5k points