I have a binary classification problem, with a dataset comprising of several features. When I train LogisticRegression
on it, I get large number of false positives and false negatives. This is totally ok, however I would like to train my model such that the data which consists of larger feature value of some specific feature f1
is given more weightage, with weight proportional to value of f1
. The end goal is to train the model to be more precise on data where feature f1
is large such that false positives and false negatives contain mostly the ones with lower f1
values. Is there any way to approach this problem?
$\begingroup$
$\endgroup$
2
-
$\begingroup$ A suggestion: pick a different name from f1, as that makes it look like you want to do something with the F1 score. // Why? Part of the point of regression and even machine learning more broadly is to let the algorithm go figure out this kind of relationship. $\endgroup$– DaveCommented Dec 29, 2021 at 1:18
-
$\begingroup$ re:Dave's comment: here it's not the relationship between the feature and the target that OP would like to specify; rather it's just the relative importance of observations. $\endgroup$– Ben Reiniger ♦Commented May 13 at 1:10
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
This can be accomplished by weighting the samples in the loss function calculation. In sklearn
, that's done using the sample_weights
argument of the fit
method. You'd set that parameter as an array, whatever function of your f1
that's most appropriate.