The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Negative values in predictions

PapadPapad Member 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 RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 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

Answers

  • sgenzersgenzer Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 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().

    Scott

  • Telcontar120Telcontar120 RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 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 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.