How can I change the training threshold for any learning algorithm in sklearn?

Bhaskar Dhariyal

I'm trying to try to train a model using sklearn, however, I want to change the decision threshold to train the model. Most of the result I find in SO are for prediction on test set.

desertnaut

There is no threshold involved in a probabilistic classifier training (by scikit-learn or any other framework).

A threshold is necessary at inference time in order to convert the probabilistic predictions to hard labels, which in turn is necessary in order to calculate what are essentially business metrics like accuracy, precision, recall etc. But these metrics play no role at model training, where the only quantity that matters (and is minimized during model fitting) is the loss. And no threshold is involved in the computation of the loss.

In other words, hard class predictions (solely for which a threshold is required) play absolutely no role in model training, hence no threshold is involved during training whatsoever.

I kindly suggest reading the following answers of mine, for clarifying the relation between loss and accuracy (despite the titles, they are not specific to Keras, but they hold for any binary classification problem in principle):

Quoting also from the Cross Validated thread Reduce Classification Probability Threshold:

the statistical component of your exercise ends when you output a probability for each class of your new sample. Choosing a threshold beyond which you classify a new observation as 1 vs. 0 is not part of the statistics any more. It is part of the decision component.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how can I combine training set specific learned parameters with sklearn online (out-of-core) learning

How do I write this simple threshold algorithm?

How can I threshold an image?

How can I know training data is enough for machine learning

How can I get learning rate during training with AdamOptimizer?? (Tensorflow)

How intensive is training a machine learning algorithm?

How can we modify the training dataset to achieve better accuracy on the minority class for any classification algorithm?

How can I fix the error in the Q-Learning algorithm in R?

How can I accept a Rust HashMap with any hashing algorithm?

How Can I A Threshold Image of a Salience Map?

How can I change order of calculation in stack algorithm?

Machine learning algorithm score changes without any change in data or step

How can I change this to use a q table for reinforcement learning

How can I use dual_coef_ param after SVM learning in sklearn?

How I can handle any change field in Entity (Spring Boot)

How can I handle any field change in Entity (Spring Boot)

How can I change my index vector into sparse feature vector that can be used in sklearn?

What is _passthrough_scorer and How Can I Change Scorers in GridsearchCV (sklearn)?

How can I match double rows with a threshold in Spark?

How I can apply color threshold into an image created from `imagecreatefromstring`?

How can I get default value for threshold with constructor in C#?

How can I solve this problem, and what kind of algorithm is the appropriate on if any to solve it

How can I implement incremental training for xgboost?

Duplicate Training Data in Decision Tree Learning Algorithm

What is the default supervised learning training algorithm in matlab?

Can I change class_weight during training?

How can I Convert a ReadonlyArray<any> to any[]?

How do I change the __lt__ magical method so this algorithm can work ? - Python

How can I change my DFS maze algorithm to generate more than one path/be not perfect?