# Unable to fit my ML model

**URL:** https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909
**Category:** New to Julia
**Created:** [July 1, 2021, 6:32pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909 "2021-07-01T18:32:25Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Maria\_Brown](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maria_brown/32/26680_2.png) [@Maria\_Brown](https://discourse.julialang.org/u/Maria_Brown)
#### Post date: [July 1, 2021, 6:32pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909/1 "2021-07-01T18:32:25Z")

</div>

Good day. Please I have some issues with applying ML algorithmes in Julia. I am trying to apply Logistic reg algo on a Diabetes dataset. I believe i have to make sure the prédictif variables are in a table and thé target variable on another. After doing so, i tried fitting the model, and I got that error. Please what is the cause. And how do I résolve it?

```julia
using Pkg
Pkg.add("ScikitLearn")
using ScikitLearn, CSV
diabetes=CSV.read("diabetes.csv", DataFrame)
diabetes_x=(Array, diabetes[:,[1,2,3,4,5,6,7,8]]
diabetes_y=(Array, diabetes[:, 9])
@sk_import linear_model: LogisticRegression
log_reg_model= LogisticRegression()
fit!(log_reg_model, diabetes_x,diabetes_y)

```

After running the last line, I get the error shown on the image below

 ![Juliahelp2](https://global.discourse-cdn.com/julialang/original/3X/c/8/c81129a926a2f1e455d86d534a7d165180ea5f94.png)

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [July 1, 2021, 7:02pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909/2 "2021-07-01T19:02:42Z")

</div>

> [@Maria\_Brown](#):
>
> ```julia
> diabetes_x=(Array, diabetes[:,[1,2,3,4,5,6,7,8]]
> diabetes_y=(Array, diabetes[:, 9])
> 
> ```

I am not familiar with scikit, but I can help you with some minor syntax issues. These two lines aren’t doing what you think they are doing. You probably want

```julia
diabetes_x = Matrix(diabetes[:,[1,2,3,4,5,6,7,8]])
diabetes_y = diabetes[:, 9] # already returns a vector

```

---

<div class="post-metadata">

### Author: ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)
#### Post date: [July 1, 2021, 7:50pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909/3 "2021-07-01T19:50:14Z")

</div>

Welcome @Maria_Brown.  
I wasn’t able to replicate your issue bc your data wasn’t included.  
However the following seems to work on my machine

```julia
using ScikitLearn 

N = 1_000; k = 4;
diabetes_x = rand(N, k)
diabetes_y = rand(0:1, N)

@sk_import linear_model: LogisticRegression
log_reg_model= LogisticRegression()
fit!(log_reg_model, diabetes_x,diabetes_y)

```

That said, ScikitLearn.jl hasn’t been actively maintained lately.  
Have a look here:[https://github.com/cstjean/ScikitLearn.jl/pull/96](https://github.com/cstjean/ScikitLearn.jl/pull/96)

I recommend you try [MLJ](https://github.com/alan-turing-institute/MLJ.jl).jl  
They have great tutorials: [Home · MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/)

---

<div class="post-metadata">

### Author: ![Maria\_Brown](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maria_brown/32/26680_2.png) [@Maria\_Brown](https://discourse.julialang.org/u/Maria_Brown)
#### Post date: [July 1, 2021, 7:56pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909/4 "2021-07-01T19:56:15Z")

</div>

Thank you very much. I have applied your recommandations. It seem to executes without any error. The only problem now is that i don’t get the results. The accuracy, scores etc.

Thank you very much

---

<div class="post-metadata">

### Author: ![Maria\_Brown](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maria_brown/32/26680_2.png) [@Maria\_Brown](https://discourse.julialang.org/u/Maria_Brown)
#### Post date: [July 1, 2021, 7:57pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909/5 "2021-07-01T19:57:07Z")

</div>

Ok @Albert_Zevelev , Thanks for your recommandations. I will check it out.

Thank you

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [July 1, 2021, 7:58pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909/6 "2021-07-01T19:58:56Z")

</div>

Open up a new thread with that question since we seem to have addressed this one. If possible, use @Albert_Zevelev 's code so it is something we can copy and paste.

---

<div class="post-metadata">

### Author: ![Maria\_Brown](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maria_brown/32/26680_2.png) [@Maria\_Brown](https://discourse.julialang.org/u/Maria_Brown)
#### Post date: [July 1, 2021, 8:21pm UTC](https://discourse.julialang.org/t/unable-to-fit-my-ml-model/63909/7 "2021-07-01T20:21:27Z")

</div>

Thank you very much @pdeffebach . I I’ll first check out @Albert_Zevelev recommendations and try using MLJ instead. It will be an opportunity for me to learn something New.

Thank you very much
