Unable to fit my ML model

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?

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

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

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

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

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

I recommend you try MLJ.jl
They have great tutorials: Home · MLJ

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

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

Thank you

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.

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

2 Likes