I'm using Classifier Chain with logistic regression and when i try to use fit, i get
This solver needs samples of at least 2 classes in the data, but the data contains only one class: 1
but I'm pretty sure I have two classes in my data, this is my X_test
<5825x2000 sparse matrix of type '<class 'numpy.float64'>'
with 219990 stored elements in Compressed Sparse Row format>
and I have this as my y_train
:
array([[1, 0, 0, ..., 0, 1, 0],
[1, 0, 0, ..., 1, 1, 0],
[1, 0, 0, ..., 0, 1, 0],
...,
[1, 0, 0, ..., 1, 1, 0],
[1, 0, 0, ..., 0, 1, 0],
[1, 0, 0, ..., 0, 1, 0]])
and this is the part I'm trying to run
cc_clf = ClassifierChain(LogisticRegression(penalty='l1', C=1, dual=False, solver='liblinear'))
cc_clf.fit(X_train, y_train)
cc_y_pred = cc_clf.predict(X_test)
Am i using the classifier chain incorrectly? When I pass in the same data into one vs rest, it works.
clf = OneVsRestClassifier(classifier1)
clf.fit(X_train, y_train)
y_train
has both 0 and 1? $\endgroup$OneVsRestClassifier
, I think. $\endgroup$