• Register
1 vote
128 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.9k 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

36.1k points

Related questions

0 votes
1 answer 50 views
50 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 3K views
3K 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
1 vote
2 answers 303 views
303 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 66 views
66 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
0 votes
1 answer 78 views
78 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