Predicting new values in logistic regression

291 views Asked by At

I am building a logistic regression model in tensorflow to approximate a function.

When I randomly select training and testing data from the complete dataset, I get a good result like so (blue are training points; red are testing points, the black line is the predicted curve):

enter image description here

But when I select the spatially seperate testing data, I get terrible predicted curve like so:

enter image description here

I understand why this is happening. But shouldn't a machine learning model learn these patterns and predict new values?

Similar thing happens with a periodic function too:

enter image description here

Am I missing something trivial here?

P.S. I did google this query for quite some time but was not able to get a good answer.

Thanks in advance.

1

There are 1 answers

0
Aaron On BEST ANSWER
  1. What you are trying to do here is not related to logistic regression. Logistic regression is a classifier and you are doing regression.
  2. No, machine learning systems aren't smart enough to learn to extrapolate functions like you have here. When you fit the model you are telling it to find an explanation for the training data. It doesn't care what the model does outside the range of training data. If you want it to be able to extrapolate then you need to give it extra information. You could set it up to assume that the input belonged to a sine wave or a quadratic polynomial and have it find the best fitting one. However, with no assumptions about the form of the function you won't be able to extrapolate.