• Register
1 vote

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

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 68 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 mphil 2.3k points
0 votes
1 answer 4K 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 2 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 35 minutes ago psandprop 580 points
1 vote
2 answers 669 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 stewart 4k points
0 votes
1 answer 92 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 jwilliam 3.9k points