# Does ScikitLearn support sample weights for scikit-learn models that do?

**URL:** https://discourse.julialang.org/t/does-scikitlearn-support-sample-weights-for-scikit-learn-models-that-do/30815
**Category:** Machine Learning
**Created:** [November 7, 2019, 2:46am UTC](https://discourse.julialang.org/t/does-scikitlearn-support-sample-weights-for-scikit-learn-models-that-do/30815 "2019-11-07T02:46:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)
#### Post date: [November 7, 2019, 2:46am UTC](https://discourse.julialang.org/t/does-scikitlearn-support-sample-weights-for-scikit-learn-models-that-do/30815/1 "2019-11-07T02:46:59Z")

</div>

In the python scikit-learn the linear model SGDRegressor, and others, support sample weights for training. I could not guess how to access this through the ScikitLearn.jl interface. Is this not supported?

```julia
using ScikitLearn

@sk_import linear_model: SGDRegressor
model = SGDRegressor()

X = randn(100, 4)
y = X[:,1] - 2X[:,2] + 0.05*randn(100)
w = rand(100)

# works:
fit!(model, X, y)

# none of these work:
fit!(model, X, y, sample_weights=w) # scikit-learn syntax
fit!(model, X, y, weights=w) 
fit!(model, X, y, w)

```

---

<div class="post-metadata">

### Author: ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)
#### Post date: [November 19, 2019, 10:29pm UTC](https://discourse.julialang.org/t/does-scikitlearn-support-sample-weights-for-scikit-learn-models-that-do/30815/2 "2019-11-19T22:29:42Z")

</div>

Thanks to Cédric St-Jean, you use “sample\_weight” not “sample\_weights” and this appears to work; see [https://github.com/cstjean/ScikitLearn.jl/issues/64](https://github.com/cstjean/ScikitLearn.jl/issues/64)
