Negative values in predictions

PapadPapad Computer Science StudentMember Posts: 68  Guru
Hi everyone,
I am making predictions but I don't want my results to have negative values ( even if I wanted there can't be in the dataset I have).
How could I handle it?
Thanks in advance.

Best Answer

  • Telcontar120Telcontar120 Posts: 1,316   Unicorn
    Solution Accepted
    @Papad The issue is that with a numerical label, although you may not have observed negative values in your training dataset, if the model is based on functions, then new input values could lead to a negative prediction via extrapolation.  The only ways to NEVER get negative predicted values would either be to use a model that inherently cannot predict negative values (such as certain types of link functions in GLM models such as Poisson or logistic) or to use a model that does not extrapolate (e.g., certain types of tree models).  Otherwise you cannot guarantee that the model will not see new input data and generate a prediction outside the previously predicted range (which could be negative).

    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts


  • sgenzersgenzer 12Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,880  Community Manager
    @Papad do you just want to take the absolute value of a set of values / results? Generate Attributes will do this nicely with abs().


  • Telcontar120Telcontar120 Moderator, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,316   Unicorn
    Or if you are getting negative values from extrapolation (such as the result of a linear regression or similar model), then probably setting a floor of zero (or whatever your desired minimum value is) would be better than absolute value.  So you can do that with Generate Attributes and an IF statement like IF(att1<0,0,att1).

    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts
  • PapadPapad Computer Science Student Member Posts: 68  Guru
    edited July 2019
    Hi @Telcontar120 ,
    I think that the way you suggest is just to change values that my model will produce, but what I want is my model from its own not to give negative values.
    To make it more clear, the dataset I have will never include negative values, it is impossible . So I want my model to know it in order to give positive values. 
    Probably the solution you give won't affect too much the accuracy because maybe we talk for one or two values in a collection of 1000.
    Although I will try what you suggest.
    Thanks again.
Sign In or Register to comment.