# Error when calling ScikitLearn from a function in a Package

**URL:** <https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131>\
**Category:** General Usage\
**Tags:** package\
**Created:** [September 6, 2020, 7:00am UTC](https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131 "2020-09-06T07:00:52Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 8, 2020, 7:03am UTC](https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131/8 "2020-09-08T07:03:13Z")

</div>

Thanks! This works,

```julia
using ScikitLearn, PyCall

const LogisticRegression = PyNULL()

function __init__ ()
    @eval @sk_import linear_model: LogisticRegression
end

function logistic_skl(points::AbstractMatrix{<:Real}, labels::AbstractVector{Bool})
    log_reg = fit!(LogisticRegression(penalty="l2"), points', labels)
    w = vec(log_reg.coef_)
    b = only(log_reg.intercept_)
    return w, b
end

```

However, I do get a warning from modifying the `const`:

> WARNING: redefinition of constant LogisticRegression. This may fail, cause incorrect answers, or produce other errors.

So I suppose there should still be a better way.

---

_[View the full topic](https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131)._
