2
$\begingroup$

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?

$\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$
    – Dave
    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
    May 13 at 1:10

1 Answer 1

0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.