kinjal gosai
kinjal gosai

Reputation: 1

ValueError: pos_label=1 is not a valid label: array(['COLLECTION', 'PAIDOFF'], dtype='<U10')

I have face this error of pos_label firstly I import this library

from sklearn.metrics import jaccard_similarity_score

because of Version error I again import this library

from sklearn.metrics import jaccard_score

This is my code for running:

depth_range = range(1, 10)
jaccard_similarity_score_ = []
f1_score_ = []

for d in depth_range:
    dt = DecisionTreeClassifier(criterion = 'gini', max_depth = d)
    dt.fit(X_train, y_train)
    dt_yhat = dt.predict(X_test)
    ja = jaccard_score(y_test, dt_yhat, "yes")
    jaccard_similarity_score_.append(ja)
    f1_score_.append(f1_score(y_test, dt_yhat, average = 'weighted'))

I get this error :

ValueError: pos_label=1 is not a valid label: array(['COLLECTION', 'PAIDOFF'], dtype='<U10')

Upvotes: 0

Views: 4166

Answers (2)

s510
s510

Reputation: 2832

In the last line change the same to:

f1_score(y_test, dt_yhat, average = 'weighted', pos_label="PAID_OFF")

Upvotes: 0

Yogesh
Yogesh

Reputation: 11

You need to mention pos_label value to the category which you want to predict as 1. So, for your case, PAIDOFF will be a positive label, so include pos_label='PAIDOFF'.

Upvotes: 1

Related Questions