# Type error while using Scikit-learn and PyCall for logistic regression

**URL:** <https://discourse.julialang.org/t/type-error-while-using-scikit-learn-and-pycall-for-logistic-regression/26410>\
**Category:** Machine Learning\
**Created:** [July 16, 2019, 10:24am UTC](https://discourse.julialang.org/t/type-error-while-using-scikit-learn-and-pycall-for-logistic-regression/26410 "2019-07-16T10:24:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![richie96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/richie96/32/9353_2.png) [@richie96](https://discourse.julialang.org/u/richie96)\
**Post date:** [July 16, 2019, 10:24am UTC](https://discourse.julialang.org/t/type-error-while-using-scikit-learn-and-pycall-for-logistic-regression/26410/1 "2019-07-16T10:24:31Z")

</div>

Hi,

I have been trying to change a python code into Julia and when trying to fit the Logisic regression model using:

@sk\_import linear\_model: LogisticRegression  
model = fit!(LogisticRegression(multi\_class=“multinomial”), X\_train, y\_train)

I am getting the following error.

PyError ($(Expr(:escape, :(ccall(#= /home/ajay/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44 =# @pysym(:PyObject\_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) \<class ‘TypeError’\>  
TypeError(“float() argument must be a string or a number, not ‘PyCall.jlwrap’”,)  
File “/home/ajay/.local/lib/python3.5/site-packages/sklearn/linear\_model/logistic.py”, line 1532, in fit  
accept\_large\_sparse=solver != ‘liblinear’)  
File “/home/ajay/.local/lib/python3.5/site-packages/sklearn/utils/validation.py”, line 719, in check\_X\_y  
estimator=estimator)  
File “/home/ajay/.local/lib/python3.5/site-packages/sklearn/utils/validation.py”, line 496, in check\_array  
array = np.asarray(array, dtype=dtype, order=order)  
File “/home/ajay/.local/lib/python3.5/site-packages/numpy/core/numeric.py”, line 538, in asarray  
return array(a, dtype, copy=False, order=order)

Stacktrace:  
[1] pyerr\_check at /home/ajay/.julia/packages/PyCall/ttONZ/src/exception.jl:60 [inlined]  
[2] pyerr\_check at /home/ajay/.julia/packages/PyCall/ttONZ/src/exception.jl:64 [inlined]  
[3] macro expansion at /home/ajay/.julia/packages/PyCall/ttONZ/src/exception.jl:84 [inlined]  
[4] \_\_pycall!(::PyObject, ::Ptr{PyCall.PyObject\_struct}, ::PyObject, ::Ptr{Nothing}) at /home/ajay/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44  
[5] \_pycall!(::PyObject, ::PyObject, ::Tuple{SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}},SubArray{Int64,1,CSV.Column{Int64,Int64},Tuple{Array{Int64,1}},false}}, ::Int64, ::Ptr{Nothing}) at /home/ajay/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:29  
[6] \_pycall!(::PyObject, ::PyObject, ::Tuple{SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}},SubArray{Int64,1,CSV.Column{Int64,Int64},Tuple{Array{Int64,1}},false}}, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/ajay/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:11  
[7] #call#111(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::PyObject, ::SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}}, ::Vararg{Any,N} where N) at /home/ajay/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89  
[8] (::PyObject)(::SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}}, ::Vararg{Any,N} where N) at /home/ajay/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89  
[9] #fit!#31(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::PyObject, ::SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}}, ::Vararg{Any,N} where N) at /home/ajay/.julia/packages/ScikitLearn/HK6Vs/src/Skcore.jl:100  
[10] fit!(::PyObject, ::SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}}, ::SubArray{Int64,1,CSV.Column{Int64,Int64},Tuple{Array{Int64,1}},false}) at /home/ajay/.julia/packages/ScikitLearn/HK6Vs/src/Skcore.jl:100  
[11] top-level scope at In[57]:1

The dataset I am using has no missing values and all the columns are either Integers or Float data type.

Can anyone help me with figuring out how to rectify the above mentioned error?

Thanks
