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

Giorgos Myrianthous
Towards Data Science
4 min readApr 5, 2022

Photo by Federica Giusti on Unsplash

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…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Written by Giorgos Myrianthous

I strive to build data-intensive systems that are not only functional, but also scalable, cost effective and maintainable over the long term.

Responses (1)

What are your thoughts?

OMG! Thankyouuuuu sooo much! I was not able to move forward due to this error, but ur solution did the job!