JuliaAI / MLJ.jl

A Julia machine learning framework
https://juliaai.github.io/MLJ.jl/
Other
1.78k stars 156 forks source link

Error MLJ in linux #833

Closed refrancesco6 closed 3 years ago

refrancesco6 commented 3 years ago

Hello, good evening dear everyone, I have the following problem with MLJ, I am on linux and I have this error: I did the following: ENV ["PYTHON"] = "/ start / francesco / anaconda3 / envs / MLJ / bin / python3" Pkg.build ("PyCall")

But then it asked me to install sklearn with conda or pip, I did and this error started to appear, could you help me, thank you very much. Hugs

Error:

julia> a = evaluate(ls_m,x,y,measure=[mae, rmse], verbosity=1, repeats=1, resampling=CV(nfolds=5)) ┌ Error: Problem fitting the machine Machine{LassoRegressor,…} @225. └ @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/machines.jl:484 [ Info: Running type checks... [ Info: Type checks okay. ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/francesco/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'ValueError'> ValueError("Input contains NaN, infinity or a value too large for dtype('float64').") File "/home/francesco/anaconda3/envs/MLJ/lib/python3.7/site-packages/sklearn/linear_model/_coordinate_descent.py", line 775, in fit y_numeric=True) File "/home/francesco/anaconda3/envs/MLJ/lib/python3.7/site-packages/sklearn/base.py", line 433, in _validate_data X, y = check_X_y(X, y, check_params) File "/home/francesco/anaconda3/envs/MLJ/lib/python3.7/site-packages/sklearn/utils/validation.py", line 63, in inner_f return f(*args, *kwargs) File "/home/francesco/anaconda3/envs/MLJ/lib/python3.7/site-packages/sklearn/utils/validation.py", line 881, in check_X_y ensure_2d=False, dtype=None) File "/home/francesco/anaconda3/envs/MLJ/lib/python3.7/site-packages/sklearn/utils/validation.py", line 63, in inner_f return f(args, kwargs) File "/home/francesco/anaconda3/envs/MLJ/lib/python3.7/site-packages/sklearn/utils/validation.py", line 721, in check_array allow_nan=force_all_finite == 'allow-nan') File "/home/francesco/anaconda3/envs/MLJ/lib/python3.7/site-packages/sklearn/utils/validation.py", line 106, in _assert_all_finite msg_dtype if msg_dtype is not None else X.dtype)

Stacktrace: [1] pyerr_check @ ~/.julia/packages/PyCall/BD546/src/exception.jl:62 [inlined] [2] pyerr_check @ ~/.julia/packages/PyCall/BD546/src/exception.jl:66 [inlined] [3] _handle_error(msg::String) @ PyCall ~/.julia/packages/PyCall/BD546/src/exception.jl:83 [4] macro expansion @ ~/.julia/packages/PyCall/BD546/src/exception.jl:97 [inlined] [5] #107 @ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 [inlined] [6] disable_sigint @ ./c.jl:458 [inlined] [7] __pycall! @ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:42 [inlined] [8] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{Matrix{Float64}, Vector{Float64}}, nargs::Int64, kw::Ptr{Nothing}) @ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:29 [9] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{Matrix{Float64}, Vector{Float64}}, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:11 [10] (::PyCall.PyObject)(::Matrix{Float64}, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:86 [11] (::PyCall.PyObject)(::Matrix{Float64}, ::Vararg{Any, N} where N) @ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:86 [12] fit!(::PyCall.PyObject, ::Matrix{Float64}, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ ScikitLearn.Skcore ~/.julia/packages/ScikitLearn/ssekP/src/Skcore.jl:102 [13] fit!(::PyCall.PyObject, ::Matrix{Float64}, ::Vector{Float64}) @ ScikitLearn.Skcore ~/.julia/packages/ScikitLearn/ssekP/src/Skcore.jl:102 [14] fit(model::MLJScikitLearnInterface.LassoRegressor, verbosity::Int64, X::DataFrame, y::Vector{Float64}) @ MLJScikitLearnInterface ~/.julia/packages/MLJScikitLearnInterface/XZkiE/src/macros.jl:149 [15] fit_only!(mach::Machine{MLJScikitLearnInterface.LassoRegressor, true}; rows::Vector{Int64}, verbosity::Int64, force::Bool) @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/machines.jl:482 [16] #fit!#98 @ ~/.julia/packages/MLJBase/rN59G/src/machines.jl:549 [inlined] [17] fit_and_extract_on_fold @ ~/.julia/packages/MLJBase/rN59G/src/resampling.jl:968 [inlined] [18] (::MLJBase.var"#265#266"{MLJBase.var"#fit_and_extract_on_fold#287"{Vector{Tuple{Vector{Int64}, UnitRange{Int64}}}, Nothing, Nothing, Int64, Vector{MLJBase.Measure}, typeof(predict), Bool, Bool, Vector{Float64}, DataFrame}, Machine{MLJScikitLearnInterface.LassoRegressor, true}, Int64, ProgressMeter.Progress})(k::Int64) @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/resampling.jl:812 [19] _mapreduce(f::MLJBase.var"#265#266"{MLJBase.var"#fit_and_extract_on_fold#287"{Vector{Tuple{Vector{Int64}, UnitRange{Int64}}}, Nothing, Nothing, Int64, Vector{MLJBase.Measure}, typeof(predict), Bool, Bool, Vector{Float64}, DataFrame}, Machine{MLJScikitLearnInterface.LassoRegressor, true}, Int64, ProgressMeter.Progress}, op::typeof(vcat), #unused#::IndexLinear, A::UnitRange{Int64}) @ Base ./reduce.jl:408 [20] _mapreduce_dim @ ./reducedim.jl:318 [inlined] [21] #mapreduce#672 @ ./reducedim.jl:310 [inlined] [22] mapreduce @ ./reducedim.jl:310 [inlined] [23] _evaluate!(func::MLJBase.var"#fit_and_extract_on_fold#287"{Vector{Tuple{Vector{Int64}, UnitRange{Int64}}}, Nothing, Nothing, Int64, Vector{MLJBase.Measure}, typeof(predict), Bool, Bool, Vector{Float64}, DataFrame}, mach::Machine{MLJScikitLearnInterface.LassoRegressor, true}, #unused#::CPU1{Nothing}, nfolds::Int64, verbosity::Int64) @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/resampling.jl:811 [24] evaluate!(mach::Machine{MLJScikitLearnInterface.LassoRegressor, true}, resampling::Vector{Tuple{Vector{Int64}, UnitRange{Int64}}}, weights::Nothing, class_weights::Nothing, rows::Nothing, verbosity::Int64, repeats::Int64, measures::Vector{MLJBase.Measure}, operation::typeof(predict), acceleration::CPU1{Nothing}, force::Bool) @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/resampling.jl:1003 [25] evaluate!(::Machine{MLJScikitLearnInterface.LassoRegressor, true}, ::CV, ::Nothing, ::Nothing, ::Nothing, ::Int64, ::Int64, ::Vector{MLJBase.Measure}, ::Function, ::CPU1{Nothing}, ::Bool) @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/resampling.jl:1069 [26] evaluate!(mach::Machine{MLJScikitLearnInterface.LassoRegressor, true}; resampling::CV, measures::Nothing, measure::Vector{MLJBase.Measure}, weights::Nothing, class_weights::Nothing, operation::Function, acceleration::CPU1{Nothing}, rows::Nothing, repeats::Int64, force::Bool, check_measure::Bool, verbosity::Int64) @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/resampling.jl:778 [27] evaluate(::MLJScikitLearnInterface.LassoRegressor, ::DataFrame, ::Vararg{Any, N} where N; cache::Bool, kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:measure, :verbosity, :repeats, :resampling), Tuple{Vector{MLJBase.Measure}, Int64, Int64, CV}}}) @ MLJBase ~/.julia/packages/MLJBase/rN59G/src/resampling.jl:791 [28] top-level scope @ REPL[51]:1

ablaom commented 3 years ago

@refrancesco6 Thanks for reporting.

ValueError("Input contains NaN, infinity or a value too large for dtype('float64').")

This suggests some kind of overflow, although another possibility is a problem with the python installation. Probably neither of these are MLJ related.

Can you reproduce the error with some data you are willing to share? You can generate synthetic data with X, y = make_regression(). What if you use a linear model from a non-python package, such as model = (@load LassoRegressor pkg=MLJLinearModels)()?

Without a minimum working example, it's hard for me to diagnose the problem.

refrancesco6 commented 3 years ago

Thank you for your response dear @ablaom. I was able to fix by reviewing my data, they had "NAN" missing values ​​and it worked. A hug