How To Fix ValueError: Unknown label type: 'continuous'
In scikit-learn
Understanding what is causing ValueError for continuous variables in scikit-learn and how to get rid of it
Introduction
People who are fairly new to Machine Learning and Python Programming may experience some troubles when attempting to train a model using scikit-learn
package.
One of the most commonly reported problems is related to the type of the target variable that may trigger specific errors when an inappropriate value is observed. One such error is the ValueError: Unknown label type: 'continuous'
whose full traceback is shared below.
Traceback (most recent call last):
File "test.py", line 14, in <module>
clf.fit(train_X, train_Y)
File "/usr/local/lib/python3.7/site-packages/sklearn/linear_model/_logistic.py", line 1347, in fit
check_classification_targets(y)
File "/usr/local/lib/python3.7/site-packages/sklearn/utils/multiclass.py", line 183, in check_classification_targets
raise ValueError("Unknown label type: %r" % y_type)
ValueError: Unknown label type: 'continuous'
In today’s short tutorial we will attempt to reproduce the error, understand why this particular exception is being raised and finally showcase how to deal…