Logistic Regression not working because of unknown label type continuous

0 votes

I'm trying to implement a logistic regression with Sklearn. Currentely I have a Dataframe which consists of 12 input variables and 1 output variable.

The output dataframe is binary valued whereas the remaining 12 variables are not necessarily so.

Example how the input data is structured.

#PseudoCode (Y and X are pandas dataframes)
Y = 0, 1, 0, 1, 1, 1  # Output data
X =  A1: 1, 1, 2, 1, 2, 2 #Input Data
     B2: 45, 23, 12, 56, 23, 86
     ...
     L12: 4.2, 3.2, 1.2, 2.3, 2.3, 9.9

Then with that the following is done:

X = X.astype(int) # to make sure that the data is actually in int format.
Y = Y.astype(int)

X_train, X_test, y_train, y_test = train_test_split(X,Y,test_size=.10, random_state = 42)

xscaler = StandardScaler()
yscaler = StandardScaler()

pipe = Pipeline([('scaler', xscaler), ('logit', LogisticRegression())]) 
model = TransformedTargetRegressor(regressor=pipe, transformer=yscaler)
model.fit(X_train,y_train)

This however, throws out the following:

ValueError: Unknown label type: 'continuous'

Why does this happen even though the Y data is clearly binary valued?

Mar 4, 2022 in Machine Learning by Nandini
• 5,480 points
3,597 views

1 answer to this question.

0 votes

The issue is because you're using a StandardScaler to scale your labels ().

x is a categorical variable that indicates whether a sample belongs to class 1 or class 0 and, as such, should not be scaled.

Elevate Your Expertise with Our Machine Learning Certification Program!

answered Mar 8, 2022 by Dev
• 6,000 points

Related Questions In Machine Learning

0 votes
1 answer

Different types of Logistic Regression

There are three main types of logistic ...READ MORE

answered May 13, 2019 in Machine Learning by Nikhil
11,790 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,352 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP