How do I set the desired treshold at the model training stage?
Hi, everybody, I have an algorithm:
clf = LGBMClassifier()
clf.fit(X_train, y_train)
When I use this algorithm to predict the probabilities of a binary classification clf.predict(X_test)
, the algorithm uses treshold=0.5
to determine the classification class.
I can change the treshold when using predict_proba
, but this option is not very suitable for me.
I am interested in whether it is possible to set the treshold
value I need at the fit
stage (training the model)?
I.e. for example, I want that when treshold>=0.6, class 1 was predicted, and class 2 was predicted for treshold fit
0
Author: ivan100096, 2020-03-05
1 answers
Solved the question:
class_distrib = {0:treshold, 1:1-treshold}
clf = LGBMClassifier(class_weight = class_distrib)
clf.fit(X_train, y_train)
Thank you for your answers
0
Author: ivan100096, 2020-03-05 15:01:26