Last answered:

08 Dec 2022

Posted on:

08 Dec 2022

0

Error: ValueError: endog must be in the unit interval.

Hi guys, and thank you for the great course!

I get an error after executing:

x = sm.add_constant(x1)
reg_log = sm.Logit(y,x)
results_log = reg_log.fit()
results_log.summary()

that says:
ValueError: endog must be in the unit interval.

It happens with any virtual environment and any data.image

2 answers ( 0 marked as helpful)
Instructor
Posted on:

08 Dec 2022

0

Hey Val,

Thank you for reaching out and thank you for the positive feedback on the course! We're really happy you enjoy it!

In your error message, endog refers to endogenous response variable, that is, the dependent (y) variable. Since Logit() is a classification model that predicts the probability of a certain outcome, the y variable needs to represent probabilities, namely, values between 0 and 1.

In your code, you have declared the y variable as data['Price']. If you wish to predict a continuous quantity such as the price of a house, then a regression model of some sort would be more appropriate. A Logit model would be appropriate for binary classification problems such as, for example, predicting whether a house would be sold or not.

In summary, the reason you're getting the error is because you allow the y-variable to bear values outside the interval [0, 1]. What you should do is to either use a regression model for your problem (if you want to predict the price), or change your target to, for example, data['Sold'].

Hope this helps!

Kind regards,
365 Hristina

Posted on:

08 Dec 2022

0

Thank you for the prompt answer, Hristina!

I fixed the issue!

Best,
Val

Submit an answer