• Register
1 vote
433 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 145 views
145 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
0 votes
2 answers 26 views
26 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 5.1K views
5.1K views
Problem : I am using Pandas 0.20.3 in my python 3.X. I for the first time and want to add one column in a pandas data frame from the other pandas data frame. My both the data frame contains 51 rows. So I tried following code: class_df['phone']=group['phone ... when I type(group['phone']) it returns the pandas.core.series.Series Can anyone suggest me what changes I need to do to remove above error?
asked Nov 27, 2019 alecxe 7.5k points
0 votes
1 answer 8 views
8 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 6 days ago Mashhoodch 5.6k points
0 votes
1 answer 18 views
18 views
I wanna use scikit-learn. I have typed pip install -U scikit-learn pip3 install sklearn to install it; but when i type $ Python >>> import sklearn it returns ImportError: No module named sklearn I followed other tutorials, but it doesn't work. Furthermore, my enviroment ... . What is the true code to type in the terminal? I tried to type python setup.py installin the terminal but it doesn't work
asked Oct 24, 2020 psandprop 2.4k points
1 vote
2 answers 1.1K views
1.1K views
Problem : Currently I am trying to develop the tweet classifier. I have already trained the knn classifier with the tfidf dataset. In this dataset each and every row has the length of 3.173. After training a model it will load it into the file to ... my training data efficiently. Please find below the error which I am facing. ValueError: query data dimension must match training data dimension.
asked Apr 23, 2020 stewart 4k points
0 votes
1 answer 114 views
114 views
Problem : I have below error for trying to load the saved SVM model. I have tried uninstalling the sklearn, NumPy and SciPy, and reinstalling a latest versions all-together again (using pip). I am still facing below error. “Runtimewarning : Numpy.dtype size changed, may indicate binary incompatibility” How to get rid of the above mentioned issue?
asked Jan 21, 2020 jwilliam 3.9k points
0 votes
1 answer 125 views
125 views
Problem : Help needed with this error runtimewarning: numpy.dtype size changed, may indicate binary incompatibility. expected 96, got 88
asked Nov 8, 2019 peterlaw 6.9k points
0 votes
1 answer 29 views
29 views
As someone new to python. can anyone tell me why we set random state to zero in splitting train and test set. I'm kind of new to python. can anyone tell me why we set random state to zero in splitting train and test set. X_train, X_test, y_train, y_test ... , y_test = \ train_test_split(X, y, test_size=0.30, random_state=1) What is the consequence of this random state in cross validation as well?
asked Oct 27, 2020 psandprop 2.4k points