dreamquark-ai / tabnet

PyTorch implementation of TabNet paper : https://arxiv.org/pdf/1908.07442.pdf
https://dreamquark-ai.github.io/tabnet/
MIT License
2.55k stars 470 forks source link

Specify the Continuous Prediction Range #472

Closed zjgbz closed 1 year ago

zjgbz commented 1 year ago

Feature request

What is the expected behavior? I expect to have a handle to restrict the range of the prediction of tabnet regression function.

What is motivation or use case for adding/changing the behavior? In computational biology, there are lots of regression tasks with outcome in certain range, and the range is physiological meaningful. For example, in linkage disequilibrium score square ranges from 0 to 1. In XGBoost, theree is reg:logit, and I expect similar and more flexible range restriction.

How should this be implemented in your opinion? The first idea in my mind is to start from the tabnet classification function and modify the last activation function to achieve the reg:logit first, and then thinking about more flexible range restriction.

Are you willing to work on this yourself? yes, but may I have your suggestions about whether this works for tabnet from the technical perspective.

Optimox commented 1 year ago

You can customize the tabnet regressor. There is no activation in the regressor for this reason. So you should create your custom loss function which applies your desired activation then your loss: something like mse(3*sigmoid(y_pred)) if you want to predict between 0 and 3.

Then you should customize your metric so that it applies the activation before computing your metric my_metric(my_activation(y_pred))

Finally when you make your prediction you should not forget to pass the output through the activation function.

Please have a look at the custom example notebook on how to do all this.

zjgbz commented 1 year ago

You can customize the tabnet regressor. There is no activation in the regressor for this reason. So you should create your custom loss function which applies your desired activation then your loss: something like mse(3*sigmoid(y_pred)) if you want to predict between 0 and 3.

Then you should customize your metric so that it applies the activation before computing your metric my_metric(my_activation(y_pred))

Finally when you make your prediction you should not forget to pass the output through the activation function.

Please have a look at the custom example notebook on how to do all this.

Hi @Optimox ,

This is really smart design and I will try that to see if it fit the task. And if everything is fine, I will close this. Thank you very much.

Best regards, zjgbz

Optimox commented 1 year ago

Please feel free to reopen if you still have questions regarding this issue.