4

fit method of LogisticRegression has a optional sample_weight parameter. I follow the python code and find it just does some trivial things and dispatches to underlying solvers (e.g. liblinear). How sample_weight works? does it work thought oversampling or some other method?

update

as @Alexander McFarlane said, it isn't immediately obvious that the sample weight in the decision tree is the same as the logistic regression unless you look at the source.

FooBee
  • 778
  • 7
  • 23
  • It's hard to answer this in detail but I can only assume sample weight might be an initial bias vector. This can be used to help center the input data on the sigmoid – Alexander McFarlane Aug 09 '17 at 12:58
  • Have you looked at the [documentation](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression.fit)? – Vivek Kumar Aug 09 '17 at 12:58
  • And maybe searched the stackoverflow for some closely related questions? https://stackoverflow.com/questions/34389624/what-does-sample-weight-do-to-the-way-a-decisiontreeclassifier-works-in-skle – Vivek Kumar Aug 09 '17 at 13:00
  • 5
    @VivekKumar I would argue that it isn't immediately obvious that the sample weight in the decision tree is the same as the logistic regression unless you look at the source. – Alexander McFarlane Aug 09 '17 at 13:03
  • Possible duplicate of [What does \`sample\_weight\` do to the way a \`DecisionTreeClassifier\` works in sklearn?](https://stackoverflow.com/questions/34389624/what-does-sample-weight-do-to-the-way-a-decisiontreeclassifier-works-in-skle) – Spacedman Aug 09 '17 at 13:09
  • @AlexanderMcFarlane Yes, I agree. But the underlying concept is almost same, of augmenting the probabilities (giving more attention to those samples than others which have higher weights). – Vivek Kumar Aug 09 '17 at 13:17
  • @VivekKumar either way - you were very helpful in finding that original answer so I deleted mine – Alexander McFarlane Aug 09 '17 at 13:31
  • 3
    @VivekKumar I've read the documentation carefully before ask. only usage is documented, and what I'm curious about is how it works (mechanism), not how to use it – FooBee Aug 09 '17 at 16:35

0 Answers0