Python Logistic Regression Error (can not see 2 classes in target variable).


I would like to run a simple python code (Logistic Regression) inside a KNIME workflow but it fails.

Although the script works fine in Anacoda (I connected the KNIME workflow with Anaconda), when I try to run the same script inside KNIME, the code fails.

I get the following error:
“This solver needs samples of at least 2 classes in the data, but the data contains only one class: ‘1’”
(I have 2 classes, 0 & 1)

After spending a lot of time in “googling” this, it seems that in some cases, there is a bug in “sklearn”. Tried to fix this by shuffling the dataset but still the same error.

The question here is, why this does not fail in Anacoda, but only inside KNIME (same dataset, same code, same environment).

Could someone help me with this?

Many thanks! :slightly_smiling_face:


Hi Christos,

Are you experiencing this issue only when executing the Python code from the Python node’s dialog (i.e., the node’s Python code editor) or also when ordinarily executing the entire node from within KNIME’s workflow editor? The reason I ask this is that in the first case, only a fixed number of data rows (1000 by default) are loaded into the node for performance reasons, which by coincidence could all be of the same class.



Hi Marcel,

It worked! :slight_smile:

Thank you so much for your help! Much appreciated!

Have a nice day Marcel! :slight_smile:



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.